Expand description
Native Rust/tch LoFTR feature matching.
This crate exposes a small, high-level API for constructing a LoFTR model,
loading compatible weights, and matching a pair of images.
Typical usage:
- Build a
LoftrModelwith a presetLoftrConfig. - Load exported weights with
LoftrModel::load_weights. - Run
LoftrModel::forwardorLoftrModel::forward_debug.
The published docs are built with the doc-only feature so they can render
on docs.rs without linking libtorch. For local runs, either point tch at
an existing libtorch install or enable the download-libtorch feature.
§Example
use loftr::{LoftrConfig, LoftrModel};
use tch::{Device, Kind, Tensor};
let mut model = LoftrModel::new(Device::Cpu, LoftrConfig::outdoor())?;
model.load_weights("artifacts/weights/loftr_outdoor_state_dict.safetensors")?;
let image0 = Tensor::rand([1, 1, 128, 128], (Kind::Float, Device::Cpu));
let image1 = Tensor::rand([1, 1, 128, 128], (Kind::Float, Device::Cpu));
let matches = model.forward(&image0, &image1)?;
println!("match count = {}", matches.confidence.size()[0]);Structs§
- Coarse
Debug Stats - Summary statistics for coarse-stage matching outputs.
- Fine
Config - Transformer parameters for the fine matching refinement stage.
- Loftr
Config - High-level
LoFTRmodel configuration. - Loftr
Debug Stages - Debug-stage summary returned by
LoFTRModel::forward_debug. - Loftr
Matches - Matched keypoints and confidences returned by
LoFTRinference. - Loftr
Model LoFTRmodel instance with owned weights and inference state.- Match
Coarse Config - Matching parameters for the coarse
LoFTRcorrespondence stage. - ResNet
FpnConfig - Backbone parameters for the
ResNetFPNencoder used byLoFTR. - Tensor
Debug Stats - Summary statistics for a tensor captured during debug inference.
- Transformer
Config - Transformer parameters shared by
LoFTRcoarse and fine stages.
Enums§
- Attention
Type - Attention implementations supported by the
LoFTRtransformers. - Backbone
Type - Backbone variants supported by this crate.
- Loftr
Error - Errors returned by the public
loftrAPI. - Match
Type - Coarse matcher implementations supported by this crate.
- Transformer
Layer - Transformer layer ordering used by
LoFTRencoder stacks.
Functions§
- normalize_
loftr_ image - Converts supported
LoFTRimage layouts into normalized[B, 1, H, W]tensors.