diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ca159c8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+.vscode/
+*.pyc
+*.DS_Store
+*.swp
+*.pth
+tmp.*
+*/.ipynb_checkpoints/*
+
+logs/
+weights/
+dump/
+src/loftr/utils/superglue.py
\ No newline at end of file
diff --git a/README.md b/README.md
index d263681..352673d 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,82 @@
![demo_vid](assets/loftr-github-demo.gif)
+## Installation
+```shell
+# For full pytorch-lightning trainer features
+conda env create -f environment.yaml
+conda activate loftr
+
+# For the LoFTR matcher only
+pip install torch einops yacs kornia
+```
+
+We provide the [download link](https://drive.google.com/drive/folders/1DOcOPZb3-5cWxLqn256AhwUVjBPifhuf?usp=sharing) to
+ - the scannet-1500-testset (~1GB).
+ - the megadepth-1500-testset (~600MB).
+ - 4 pretrained models of indoor-ds, indoor-ot, outdoor-ds and outdoor-ot (each ~45MB).
+
+By now, the LoFTR-DS model is ready to go!
+
+
+ [Requirements for LoFTR-OT]
+
+ We use the code from [SuperGluePretrainedNetwork](https://github.com/magicleap/SuperGluePretrainedNetwork) for optimal transport. However, we can't provide the code directly due to its LICENSE. We recommend downloading it instead.
+
+ ```shell
+ cd src/loftr/utils
+ wget https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/master/models/superglue.py
+ ```
+
+
+
+## Run the code
+
+### Match image pairs with LoFTR
+
+
+ [code snippets]
+
+ ```python
+ from src.loftr import LoFTR, default_cfg
+
+ # Initialize LoFTR
+ matcher = LoFTR(config=default_cfg)
+ matcher.load_state_dict(torch.load("weights/indoor_ds.ckpt")['state_dict'])
+ matcher = matcher.eval().cuda()
+
+ # Inference
+ with torch.no_grad():
+ matcher(batch) # batch = {'image0': img0, 'image1': img1}
+ mkpts0 = batch['mkpts0_f'].cpu().numpy()
+ mkpts1 = batch['mkpts1_f'].cpu().numpy()
+ ```
+
+
+
+An example is in the `notebooks/demo_single_pair.ipynb`.
+
+### Reproduce the testing results with pytorch-lightning
+
+```shell
+conda activate loftr
+# with shell script
+bash ./scripts/reproduce_test/indoor_ds.sh
+
+# or
+python test.py configs/data/scannet_test_1500.py configs/loftr/loftr_ds.py --ckpt_path weights/indoor_ds.ckpt --profiler_name inference --gpus=1 --accelerator="ddp"
+```
+
+For visualizing the dump results, please refer to `notebooks/visualize_dump_results.ipynb`.
+
+### Reproduce the training phase with pytorch-lightning
+
+The code is coming soon, stay tuned!
+
+
## Code release ETA
-We plan to release the inference-only code and pretrained model within the upcoming week, stay tuned.
The entire codebase for data pre-processing, training and validation is under major refactoring and will be released around June.
Please subscribe to [this discussion thread](https://github.com/zju3dv/LoFTR/discussions/2) if you wish to be notified of the code release.
In the meanwhile, discussions about the paper are welcomed in the [discussion panel](https://github.com/zju3dv/LoFTR/discussions).
diff --git a/assets/megadepth_test_1500_scene_info/0015_0.1_0.3.npz b/assets/megadepth_test_1500_scene_info/0015_0.1_0.3.npz
new file mode 100644
index 0000000..0e4820c
Binary files /dev/null and b/assets/megadepth_test_1500_scene_info/0015_0.1_0.3.npz differ
diff --git a/assets/megadepth_test_1500_scene_info/0015_0.3_0.5.npz b/assets/megadepth_test_1500_scene_info/0015_0.3_0.5.npz
new file mode 100644
index 0000000..44bb564
Binary files /dev/null and b/assets/megadepth_test_1500_scene_info/0015_0.3_0.5.npz differ
diff --git a/assets/megadepth_test_1500_scene_info/0022_0.1_0.3.npz b/assets/megadepth_test_1500_scene_info/0022_0.1_0.3.npz
new file mode 100644
index 0000000..af1e44c
Binary files /dev/null and b/assets/megadepth_test_1500_scene_info/0022_0.1_0.3.npz differ
diff --git a/assets/megadepth_test_1500_scene_info/0022_0.3_0.5.npz b/assets/megadepth_test_1500_scene_info/0022_0.3_0.5.npz
new file mode 100644
index 0000000..42d26c6
Binary files /dev/null and b/assets/megadepth_test_1500_scene_info/0022_0.3_0.5.npz differ
diff --git a/assets/megadepth_test_1500_scene_info/0022_0.5_0.7.npz b/assets/megadepth_test_1500_scene_info/0022_0.5_0.7.npz
new file mode 100644
index 0000000..bc6bf77
Binary files /dev/null and b/assets/megadepth_test_1500_scene_info/0022_0.5_0.7.npz differ
diff --git a/assets/megadepth_test_1500_scene_info/megadepth_test_1500.txt b/assets/megadepth_test_1500_scene_info/megadepth_test_1500.txt
new file mode 100644
index 0000000..958259d
--- /dev/null
+++ b/assets/megadepth_test_1500_scene_info/megadepth_test_1500.txt
@@ -0,0 +1,5 @@
+0022_0.1_0.3.npz
+0015_0.1_0.3.npz
+0015_0.3_0.5.npz
+0022_0.3_0.5.npz
+0022_0.5_0.7.npz
\ No newline at end of file
diff --git a/assets/phototourism_sample_images/london_bridge_19481797_2295892421.jpg b/assets/phototourism_sample_images/london_bridge_19481797_2295892421.jpg
new file mode 100644
index 0000000..83e835f
Binary files /dev/null and b/assets/phototourism_sample_images/london_bridge_19481797_2295892421.jpg differ
diff --git a/assets/phototourism_sample_images/london_bridge_49190386_5209386933.jpg b/assets/phototourism_sample_images/london_bridge_49190386_5209386933.jpg
new file mode 100644
index 0000000..8134ddc
Binary files /dev/null and b/assets/phototourism_sample_images/london_bridge_49190386_5209386933.jpg differ
diff --git a/assets/phototourism_sample_images/london_bridge_78916675_4568141288.jpg b/assets/phototourism_sample_images/london_bridge_78916675_4568141288.jpg
new file mode 100644
index 0000000..6401ec8
Binary files /dev/null and b/assets/phototourism_sample_images/london_bridge_78916675_4568141288.jpg differ
diff --git a/assets/phototourism_sample_images/london_bridge_94185272_3874562886.jpg b/assets/phototourism_sample_images/london_bridge_94185272_3874562886.jpg
new file mode 100644
index 0000000..e46d69d
Binary files /dev/null and b/assets/phototourism_sample_images/london_bridge_94185272_3874562886.jpg differ
diff --git a/assets/phototourism_sample_images/piazza_san_marco_06795901_3725050516.jpg b/assets/phototourism_sample_images/piazza_san_marco_06795901_3725050516.jpg
new file mode 100644
index 0000000..cc42580
Binary files /dev/null and b/assets/phototourism_sample_images/piazza_san_marco_06795901_3725050516.jpg differ
diff --git a/assets/phototourism_sample_images/piazza_san_marco_15148634_5228701572.jpg b/assets/phototourism_sample_images/piazza_san_marco_15148634_5228701572.jpg
new file mode 100644
index 0000000..d37c9bc
Binary files /dev/null and b/assets/phototourism_sample_images/piazza_san_marco_15148634_5228701572.jpg differ
diff --git a/assets/phototourism_sample_images/piazza_san_marco_18627786_5929294590.jpg b/assets/phototourism_sample_images/piazza_san_marco_18627786_5929294590.jpg
new file mode 100644
index 0000000..96e09ab
Binary files /dev/null and b/assets/phototourism_sample_images/piazza_san_marco_18627786_5929294590.jpg differ
diff --git a/assets/phototourism_sample_images/piazza_san_marco_43351518_2659980686.jpg b/assets/phototourism_sample_images/piazza_san_marco_43351518_2659980686.jpg
new file mode 100644
index 0000000..5034cfe
Binary files /dev/null and b/assets/phototourism_sample_images/piazza_san_marco_43351518_2659980686.jpg differ
diff --git a/assets/phototourism_sample_images/piazza_san_marco_58751010_4849458397.jpg b/assets/phototourism_sample_images/piazza_san_marco_58751010_4849458397.jpg
new file mode 100644
index 0000000..6574355
Binary files /dev/null and b/assets/phototourism_sample_images/piazza_san_marco_58751010_4849458397.jpg differ
diff --git a/assets/phototourism_sample_images/st_pauls_cathedral_30776973_2635313996.jpg b/assets/phototourism_sample_images/st_pauls_cathedral_30776973_2635313996.jpg
new file mode 100644
index 0000000..a7eb12c
Binary files /dev/null and b/assets/phototourism_sample_images/st_pauls_cathedral_30776973_2635313996.jpg differ
diff --git a/assets/phototourism_sample_images/st_pauls_cathedral_37347628_10902811376.jpg b/assets/phototourism_sample_images/st_pauls_cathedral_37347628_10902811376.jpg
new file mode 100644
index 0000000..badec2c
Binary files /dev/null and b/assets/phototourism_sample_images/st_pauls_cathedral_37347628_10902811376.jpg differ
diff --git a/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg b/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg
new file mode 100644
index 0000000..3e94268
Binary files /dev/null and b/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg differ
diff --git a/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg b/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg
new file mode 100644
index 0000000..c7aae1d
Binary files /dev/null and b/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg differ
diff --git a/assets/scannet_sample_images/scene0711_00_frame-001680.jpg b/assets/scannet_sample_images/scene0711_00_frame-001680.jpg
new file mode 100644
index 0000000..1f5d4a0
Binary files /dev/null and b/assets/scannet_sample_images/scene0711_00_frame-001680.jpg differ
diff --git a/assets/scannet_sample_images/scene0711_00_frame-001995.jpg b/assets/scannet_sample_images/scene0711_00_frame-001995.jpg
new file mode 100644
index 0000000..b439907
Binary files /dev/null and b/assets/scannet_sample_images/scene0711_00_frame-001995.jpg differ
diff --git a/assets/scannet_sample_images/scene0713_00_frame-001320.jpg b/assets/scannet_sample_images/scene0713_00_frame-001320.jpg
new file mode 100644
index 0000000..fe5db63
Binary files /dev/null and b/assets/scannet_sample_images/scene0713_00_frame-001320.jpg differ
diff --git a/assets/scannet_sample_images/scene0713_00_frame-002025.jpg b/assets/scannet_sample_images/scene0713_00_frame-002025.jpg
new file mode 100644
index 0000000..15dc881
Binary files /dev/null and b/assets/scannet_sample_images/scene0713_00_frame-002025.jpg differ
diff --git a/assets/scannet_sample_images/scene0721_00_frame-000375.jpg b/assets/scannet_sample_images/scene0721_00_frame-000375.jpg
new file mode 100644
index 0000000..b6a0d12
Binary files /dev/null and b/assets/scannet_sample_images/scene0721_00_frame-000375.jpg differ
diff --git a/assets/scannet_sample_images/scene0721_00_frame-002745.jpg b/assets/scannet_sample_images/scene0721_00_frame-002745.jpg
new file mode 100644
index 0000000..1925d56
Binary files /dev/null and b/assets/scannet_sample_images/scene0721_00_frame-002745.jpg differ
diff --git a/assets/scannet_sample_images/scene0722_00_frame-000045.jpg b/assets/scannet_sample_images/scene0722_00_frame-000045.jpg
new file mode 100644
index 0000000..e661870
Binary files /dev/null and b/assets/scannet_sample_images/scene0722_00_frame-000045.jpg differ
diff --git a/assets/scannet_sample_images/scene0722_00_frame-000735.jpg b/assets/scannet_sample_images/scene0722_00_frame-000735.jpg
new file mode 100644
index 0000000..1e288b8
Binary files /dev/null and b/assets/scannet_sample_images/scene0722_00_frame-000735.jpg differ
diff --git a/assets/scannet_sample_images/scene0726_00_frame-000135.jpg b/assets/scannet_sample_images/scene0726_00_frame-000135.jpg
new file mode 100644
index 0000000..27c580b
Binary files /dev/null and b/assets/scannet_sample_images/scene0726_00_frame-000135.jpg differ
diff --git a/assets/scannet_sample_images/scene0726_00_frame-000210.jpg b/assets/scannet_sample_images/scene0726_00_frame-000210.jpg
new file mode 100644
index 0000000..8b617d8
Binary files /dev/null and b/assets/scannet_sample_images/scene0726_00_frame-000210.jpg differ
diff --git a/assets/scannet_sample_images/scene0737_00_frame-000930.jpg b/assets/scannet_sample_images/scene0737_00_frame-000930.jpg
new file mode 100644
index 0000000..9fd8133
Binary files /dev/null and b/assets/scannet_sample_images/scene0737_00_frame-000930.jpg differ
diff --git a/assets/scannet_sample_images/scene0737_00_frame-001095.jpg b/assets/scannet_sample_images/scene0737_00_frame-001095.jpg
new file mode 100644
index 0000000..5733499
Binary files /dev/null and b/assets/scannet_sample_images/scene0737_00_frame-001095.jpg differ
diff --git a/assets/scannet_sample_images/scene0738_00_frame-000885.jpg b/assets/scannet_sample_images/scene0738_00_frame-000885.jpg
new file mode 100644
index 0000000..a8c916b
Binary files /dev/null and b/assets/scannet_sample_images/scene0738_00_frame-000885.jpg differ
diff --git a/assets/scannet_sample_images/scene0738_00_frame-001065.jpg b/assets/scannet_sample_images/scene0738_00_frame-001065.jpg
new file mode 100644
index 0000000..9a72e9e
Binary files /dev/null and b/assets/scannet_sample_images/scene0738_00_frame-001065.jpg differ
diff --git a/assets/scannet_sample_images/scene0743_00_frame-000000.jpg b/assets/scannet_sample_images/scene0743_00_frame-000000.jpg
new file mode 100644
index 0000000..36acdfe
Binary files /dev/null and b/assets/scannet_sample_images/scene0743_00_frame-000000.jpg differ
diff --git a/assets/scannet_sample_images/scene0743_00_frame-001275.jpg b/assets/scannet_sample_images/scene0743_00_frame-001275.jpg
new file mode 100644
index 0000000..1749022
Binary files /dev/null and b/assets/scannet_sample_images/scene0743_00_frame-001275.jpg differ
diff --git a/assets/scannet_sample_images/scene0744_00_frame-000585.jpg b/assets/scannet_sample_images/scene0744_00_frame-000585.jpg
new file mode 100644
index 0000000..f763f0f
Binary files /dev/null and b/assets/scannet_sample_images/scene0744_00_frame-000585.jpg differ
diff --git a/assets/scannet_sample_images/scene0744_00_frame-002310.jpg b/assets/scannet_sample_images/scene0744_00_frame-002310.jpg
new file mode 100644
index 0000000..18f1795
Binary files /dev/null and b/assets/scannet_sample_images/scene0744_00_frame-002310.jpg differ
diff --git a/assets/scannet_sample_images/scene0747_00_frame-000000.jpg b/assets/scannet_sample_images/scene0747_00_frame-000000.jpg
new file mode 100644
index 0000000..e290f4f
Binary files /dev/null and b/assets/scannet_sample_images/scene0747_00_frame-000000.jpg differ
diff --git a/assets/scannet_sample_images/scene0747_00_frame-001530.jpg b/assets/scannet_sample_images/scene0747_00_frame-001530.jpg
new file mode 100644
index 0000000..ddee6c5
Binary files /dev/null and b/assets/scannet_sample_images/scene0747_00_frame-001530.jpg differ
diff --git a/assets/scannet_sample_images/scene0752_00_frame-000075.jpg b/assets/scannet_sample_images/scene0752_00_frame-000075.jpg
new file mode 100644
index 0000000..91f696c
Binary files /dev/null and b/assets/scannet_sample_images/scene0752_00_frame-000075.jpg differ
diff --git a/assets/scannet_sample_images/scene0752_00_frame-001440.jpg b/assets/scannet_sample_images/scene0752_00_frame-001440.jpg
new file mode 100644
index 0000000..b2f65a3
Binary files /dev/null and b/assets/scannet_sample_images/scene0752_00_frame-001440.jpg differ
diff --git a/assets/scannet_sample_images/scene0755_00_frame-000120.jpg b/assets/scannet_sample_images/scene0755_00_frame-000120.jpg
new file mode 100644
index 0000000..c939888
Binary files /dev/null and b/assets/scannet_sample_images/scene0755_00_frame-000120.jpg differ
diff --git a/assets/scannet_sample_images/scene0755_00_frame-002055.jpg b/assets/scannet_sample_images/scene0755_00_frame-002055.jpg
new file mode 100644
index 0000000..6b73343
Binary files /dev/null and b/assets/scannet_sample_images/scene0755_00_frame-002055.jpg differ
diff --git a/assets/scannet_sample_images/scene0758_00_frame-000165.jpg b/assets/scannet_sample_images/scene0758_00_frame-000165.jpg
new file mode 100644
index 0000000..bc0a81c
Binary files /dev/null and b/assets/scannet_sample_images/scene0758_00_frame-000165.jpg differ
diff --git a/assets/scannet_sample_images/scene0758_00_frame-000510.jpg b/assets/scannet_sample_images/scene0758_00_frame-000510.jpg
new file mode 100644
index 0000000..b569954
Binary files /dev/null and b/assets/scannet_sample_images/scene0758_00_frame-000510.jpg differ
diff --git a/assets/scannet_sample_images/scene0768_00_frame-001095.jpg b/assets/scannet_sample_images/scene0768_00_frame-001095.jpg
new file mode 100644
index 0000000..aeb1e10
Binary files /dev/null and b/assets/scannet_sample_images/scene0768_00_frame-001095.jpg differ
diff --git a/assets/scannet_sample_images/scene0768_00_frame-003435.jpg b/assets/scannet_sample_images/scene0768_00_frame-003435.jpg
new file mode 100644
index 0000000..1422cf5
Binary files /dev/null and b/assets/scannet_sample_images/scene0768_00_frame-003435.jpg differ
diff --git a/assets/scannet_sample_images/scene0806_00_frame-000225.jpg b/assets/scannet_sample_images/scene0806_00_frame-000225.jpg
new file mode 100644
index 0000000..221215d
Binary files /dev/null and b/assets/scannet_sample_images/scene0806_00_frame-000225.jpg differ
diff --git a/assets/scannet_sample_images/scene0806_00_frame-001095.jpg b/assets/scannet_sample_images/scene0806_00_frame-001095.jpg
new file mode 100644
index 0000000..cc68972
Binary files /dev/null and b/assets/scannet_sample_images/scene0806_00_frame-001095.jpg differ
diff --git a/assets/scannet_test_1500/intrinsics.npz b/assets/scannet_test_1500/intrinsics.npz
new file mode 100644
index 0000000..b653fad
Binary files /dev/null and b/assets/scannet_test_1500/intrinsics.npz differ
diff --git a/assets/scannet_test_1500/scannet_test.txt b/assets/scannet_test_1500/scannet_test.txt
new file mode 100644
index 0000000..45cc7ff
--- /dev/null
+++ b/assets/scannet_test_1500/scannet_test.txt
@@ -0,0 +1 @@
+test.npz
\ No newline at end of file
diff --git a/assets/scannet_test_1500/statistics.json b/assets/scannet_test_1500/statistics.json
new file mode 100644
index 0000000..0e3ff58
--- /dev/null
+++ b/assets/scannet_test_1500/statistics.json
@@ -0,0 +1,102 @@
+{
+ "scene0707_00": 15,
+ "scene0708_00": 15,
+ "scene0709_00": 15,
+ "scene0710_00": 15,
+ "scene0711_00": 15,
+ "scene0712_00": 15,
+ "scene0713_00": 15,
+ "scene0714_00": 15,
+ "scene0715_00": 15,
+ "scene0716_00": 15,
+ "scene0717_00": 15,
+ "scene0718_00": 15,
+ "scene0719_00": 15,
+ "scene0720_00": 15,
+ "scene0721_00": 15,
+ "scene0722_00": 15,
+ "scene0723_00": 15,
+ "scene0724_00": 15,
+ "scene0725_00": 15,
+ "scene0726_00": 15,
+ "scene0727_00": 15,
+ "scene0728_00": 15,
+ "scene0729_00": 15,
+ "scene0730_00": 15,
+ "scene0731_00": 15,
+ "scene0732_00": 15,
+ "scene0733_00": 15,
+ "scene0734_00": 15,
+ "scene0735_00": 15,
+ "scene0736_00": 15,
+ "scene0737_00": 15,
+ "scene0738_00": 15,
+ "scene0739_00": 15,
+ "scene0740_00": 15,
+ "scene0741_00": 15,
+ "scene0742_00": 15,
+ "scene0743_00": 15,
+ "scene0744_00": 15,
+ "scene0745_00": 15,
+ "scene0746_00": 15,
+ "scene0747_00": 15,
+ "scene0748_00": 15,
+ "scene0749_00": 15,
+ "scene0750_00": 15,
+ "scene0751_00": 15,
+ "scene0752_00": 15,
+ "scene0753_00": 15,
+ "scene0754_00": 15,
+ "scene0755_00": 15,
+ "scene0756_00": 15,
+ "scene0757_00": 15,
+ "scene0758_00": 15,
+ "scene0759_00": 15,
+ "scene0760_00": 15,
+ "scene0761_00": 15,
+ "scene0762_00": 15,
+ "scene0763_00": 15,
+ "scene0764_00": 15,
+ "scene0765_00": 15,
+ "scene0766_00": 15,
+ "scene0767_00": 15,
+ "scene0768_00": 15,
+ "scene0769_00": 15,
+ "scene0770_00": 15,
+ "scene0771_00": 15,
+ "scene0772_00": 15,
+ "scene0773_00": 15,
+ "scene0774_00": 15,
+ "scene0775_00": 15,
+ "scene0776_00": 15,
+ "scene0777_00": 15,
+ "scene0778_00": 15,
+ "scene0779_00": 15,
+ "scene0780_00": 15,
+ "scene0781_00": 15,
+ "scene0782_00": 15,
+ "scene0783_00": 15,
+ "scene0784_00": 15,
+ "scene0785_00": 15,
+ "scene0786_00": 15,
+ "scene0787_00": 15,
+ "scene0788_00": 15,
+ "scene0789_00": 15,
+ "scene0790_00": 15,
+ "scene0791_00": 15,
+ "scene0792_00": 15,
+ "scene0793_00": 15,
+ "scene0794_00": 15,
+ "scene0795_00": 15,
+ "scene0796_00": 15,
+ "scene0797_00": 15,
+ "scene0798_00": 15,
+ "scene0799_00": 15,
+ "scene0800_00": 15,
+ "scene0801_00": 15,
+ "scene0802_00": 15,
+ "scene0803_00": 15,
+ "scene0804_00": 15,
+ "scene0805_00": 15,
+ "scene0806_00": 15
+}
\ No newline at end of file
diff --git a/assets/scannet_test_1500/test.npz b/assets/scannet_test_1500/test.npz
new file mode 100644
index 0000000..a1e07f7
Binary files /dev/null and b/assets/scannet_test_1500/test.npz differ
diff --git a/configs/data/__init__.py b/configs/data/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/configs/data/base.py b/configs/data/base.py
new file mode 100644
index 0000000..1d70c81
--- /dev/null
+++ b/configs/data/base.py
@@ -0,0 +1,31 @@
+"""
+The data config will be the last one merged into the main config.
+Setups in data configs will override all existed setups!
+"""
+
+from yacs.config import CfgNode as CN
+_CN = CN()
+_CN.DATASET = CN()
+_CN.TRAINER = CN()
+
+# training data config
+_CN.DATASET.TRAIN_DATA_ROOT = None
+_CN.DATASET.TRAIN_NPZ_ROOT = None
+_CN.DATASET.TRAIN_LIST_PATH = None
+_CN.DATASET.TRAIN_INTRINSIC_PATH = None
+# validation set config
+_CN.DATASET.VAL_DATA_ROOT = None
+_CN.DATASET.VAL_NPZ_ROOT = None
+_CN.DATASET.VAL_LIST_PATH = None
+_CN.DATASET.VAL_INTRINSIC_PATH = None
+
+# testing data config
+_CN.DATASET.TEST_DATA_ROOT = None
+_CN.DATASET.TEST_NPZ_ROOT = None
+_CN.DATASET.TEST_LIST_PATH = None
+_CN.DATASET.TEST_INTRINSIC_PATH = None
+
+# dataset config
+_CN.DATASET.MIN_OVERLAP_SCORE = 0.4
+
+cfg = _CN
diff --git a/configs/data/megadepth_test_1500.py b/configs/data/megadepth_test_1500.py
new file mode 100644
index 0000000..3d86b1e
--- /dev/null
+++ b/configs/data/megadepth_test_1500.py
@@ -0,0 +1,11 @@
+from configs.data.base import cfg
+
+TEST_BASE_PATH = "assets/megadepth_test_1500_scene_info"
+
+cfg.DATASET.TEST_DATA_SOURCE = "MegaDepth"
+cfg.DATASET.TEST_DATA_ROOT = "/data/MegaDepth/megadepth_test_1500"
+cfg.DATASET.TEST_NPZ_ROOT = f"{TEST_BASE_PATH}"
+cfg.DATASET.TEST_LIST_PATH = f"{TEST_BASE_PATH}/megadepth_test_1500.txt"
+
+cfg.DATASET.MGDPT_IMG_RESIZE = 840
+cfg.DATASET.MIN_OVERLAP_SCORE = 0.0
diff --git a/configs/data/scannet_test_1500.py b/configs/data/scannet_test_1500.py
new file mode 100644
index 0000000..e9befe9
--- /dev/null
+++ b/configs/data/scannet_test_1500.py
@@ -0,0 +1,11 @@
+from configs.data.base import cfg
+
+TEST_BASE_PATH = "assets/scannet_test_1500"
+
+cfg.DATASET.TEST_DATA_SOURCE = "ScanNet"
+cfg.DATASET.TEST_DATA_ROOT = "/data/scannet/scannet_test_1500"
+cfg.DATASET.TEST_NPZ_ROOT = f"{TEST_BASE_PATH}"
+cfg.DATASET.TEST_LIST_PATH = f"{TEST_BASE_PATH}/scannet_test.txt"
+cfg.DATASET.TEST_INTRINSIC_PATH = f"{TEST_BASE_PATH}/intrinsics.npz"
+
+cfg.DATASET.MIN_OVERLAP_SCORE = 0.0
diff --git a/configs/loftr/loftr_ds.py b/configs/loftr/loftr_ds.py
new file mode 100644
index 0000000..75616a7
--- /dev/null
+++ b/configs/loftr/loftr_ds.py
@@ -0,0 +1,3 @@
+from src.config.default import _CN as cfg
+
+cfg.LOFTR.MATCH_COARSE.MATCH_TYPE = 'dual_softmax'
diff --git a/configs/loftr/loftr_ot.py b/configs/loftr/loftr_ot.py
new file mode 100644
index 0000000..1874650
--- /dev/null
+++ b/configs/loftr/loftr_ot.py
@@ -0,0 +1,3 @@
+from src.config.default import _CN as cfg
+
+cfg.LOFTR.MATCH_COARSE.MATCH_TYPE = 'sinkhorn'
diff --git a/environment.yaml b/environment.yaml
new file mode 100644
index 0000000..4933c73
--- /dev/null
+++ b/environment.yaml
@@ -0,0 +1,14 @@
+name: loftr
+channels:
+ # - https://dx-mirrors.sensetime.com/anaconda/cloud/pytorch
+ - pytorch
+ - conda-forge
+ - defaults
+dependencies:
+ - python=3.8
+ - cudatoolkit=10.2
+ - pytorch=1.8.0
+ - pytorch-lightning<=1.1.8 # https://github.com/PyTorchLightning/pytorch-lightning/issues/6318
+ - pip
+ - pip:
+ - -r file:requirements.txt
diff --git a/notebooks/demo_single_pair.ipynb b/notebooks/demo_single_pair.ipynb
new file mode 100644
index 0000000..67bc1b3
--- /dev/null
+++ b/notebooks/demo_single_pair.ipynb
@@ -0,0 +1,204 @@
+{
+ "metadata": {
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.8-final"
+ },
+ "orig_nbformat": 2,
+ "kernelspec": {
+ "name": "python388jvsc74a57bd0e2d1507a0fcefcbd70c2e8d5c2edae879585b2c8df0be6cdbe280bf251175c7f",
+ "display_name": "Python 3.8.8 64-bit ('loftr': conda)"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "cells": [
+ {
+ "source": [
+ "# Demo LoFTR-DS on a single pair of images\n",
+ "\n",
+ "This notebook shows how to use the loftr matcher with default config(dual-softmax) and the pretrained weights."
+ ],
+ "cell_type": "markdown",
+ "metadata": {}
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import os\n",
+ "os.chdir(\"..\")\n",
+ "import torch\n",
+ "import cv2\n",
+ "import numpy as np\n",
+ "import matplotlib.cm as cm\n",
+ "from src.utils.plotting import make_matching_figure"
+ ]
+ },
+ {
+ "source": [
+ "## Indoor Example"
+ ],
+ "cell_type": "markdown",
+ "metadata": {}
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from src.loftr import LoFTR, default_cfg\n",
+ "\n",
+ "# The default config uses dual-softmax.\n",
+ "# The outdoor and indoor models share the same config.\n",
+ "# You can change the default values like thr and coarse_match_type.\n",
+ "matcher = LoFTR(config=default_cfg)\n",
+ "matcher.load_state_dict(torch.load(\"weights/indoor_ds.ckpt\")['state_dict'])\n",
+ "matcher = matcher.eval().cuda()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Load example images\n",
+ "img0_pth = \"assets/scannet_sample_images/scene0711_00_frame-001680.jpg\"\n",
+ "img1_pth = \"assets/scannet_sample_images/scene0711_00_frame-001995.jpg\"\n",
+ "img0_raw = cv2.imread(img0_pth, cv2.IMREAD_GRAYSCALE)\n",
+ "img1_raw = cv2.imread(img1_pth, cv2.IMREAD_GRAYSCALE)\n",
+ "img0_raw = cv2.resize(img0_raw, (640, 480))\n",
+ "img1_raw = cv2.resize(img1_raw, (640, 480))\n",
+ "\n",
+ "img0 = torch.from_numpy(img0_raw)[None][None].cuda() / 255.\n",
+ "img1 = torch.from_numpy(img1_raw)[None][None].cuda() / 255.\n",
+ "batch = {'image0': img0, 'image1': img1}\n",
+ "\n",
+ "# Inference with LoFTR and get prediction\n",
+ "with torch.no_grad():\n",
+ " matcher(batch)\n",
+ " mkpts0 = batch['mkpts0_f'].cpu().numpy()\n",
+ " mkpts1 = batch['mkpts1_f'].cpu().numpy()\n",
+ " mconf = batch['mconf'].cpu().numpy()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": "