METADATA 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. Metadata-Version: 2.3
  2. Name: romatch
  3. Version: 0.1.2
  4. Summary: Robust Dense Feature Matching
  5. Author: Johan Edstedt
  6. Author-email: Johan Edstedt <johan.edstedt@liu.se>
  7. Requires-Dist: albumentations
  8. Requires-Dist: einops
  9. Requires-Dist: h5py
  10. Requires-Dist: kornia
  11. Requires-Dist: loguru
  12. Requires-Dist: matplotlib
  13. Requires-Dist: opencv-python
  14. Requires-Dist: poselib>=2.0.4
  15. Requires-Dist: timm
  16. Requires-Dist: torch>=2.5.1
  17. Requires-Dist: torchvision
  18. Requires-Dist: tqdm
  19. Requires-Dist: wandb
  20. Requires-Dist: fused-local-corr>=0.2.2 ; sys_platform == 'linux' and extra == 'fused-local-corr'
  21. Requires-Python: >=3.9
  22. Provides-Extra: fused-local-corr
  23. Description-Content-Type: text/markdown
  24. #
  25. <p align="center">
  26. <h1 align="center"> <ins>RoMa</ins> 🏛️:<br> Robust Dense Feature Matching <br> ⭐CVPR 2024⭐</h1>
  27. <p align="center">
  28. <a href="https://scholar.google.com/citations?user=Ul-vMR0AAAAJ">Johan Edstedt</a>
  29. ·
  30. <a href="https://scholar.google.com/citations?user=HS2WuHkAAAAJ">Qiyu Sun</a>
  31. ·
  32. <a href="https://scholar.google.com/citations?user=FUE3Wd0AAAAJ">Georg Bökman</a>
  33. ·
  34. <a href="https://scholar.google.com/citations?user=6WRQpCQAAAAJ">Mårten Wadenbäck</a>
  35. ·
  36. <a href="https://scholar.google.com/citations?user=lkWfR08AAAAJ">Michael Felsberg</a>
  37. </p>
  38. <h2 align="center"><p>
  39. <a href="https://arxiv.org/abs/2305.15404" align="center">Paper</a> |
  40. <a href="https://parskatt.github.io/RoMa" align="center">Project Page</a>
  41. </p></h2>
  42. <div align="center"></div>
  43. </p>
  44. <br/>
  45. <p align="center">
  46. <img src="https://github.com/Parskatt/RoMa/assets/22053118/15d8fea7-aa6d-479f-8a93-350d950d006b" alt="example" width=80%>
  47. <br>
  48. <em>RoMa is the robust dense feature matcher capable of estimating pixel-dense warps and reliable certainties for almost any image pair.</em>
  49. </p>
  50. ## Setup/Install
  51. In your python environment (tested on Linux python 3.12), run:
  52. ```bash
  53. uv pip install -e .
  54. ```
  55. or
  56. ```bash
  57. uv sync
  58. ```
  59. You can also install `romatch` directly as a package from PyPI by
  60. ```bash
  61. uv pip install romatch
  62. ```
  63. or
  64. ```bash
  65. uv add romatch
  66. ```
  67. ## Fused local correlation kernel
  68. Include the `--extra fused-local-corr` flag as:
  69. ```bash
  70. uv sync --extra fused-local-corr
  71. ```
  72. or
  73. ```bash
  74. uv pip install romatch[fused-local-corr]
  75. ```
  76. or
  77. ```bash
  78. uv add romatch[fused-local-corr]
  79. ```
  80. ## Demo / How to Use
  81. We provide two demos in the [demos folder](demo).
  82. Here's the gist of it:
  83. ```python
  84. from romatch import roma_outdoor
  85. roma_model = roma_outdoor(device=device)
  86. # Match
  87. warp, certainty = roma_model.match(imA_path, imB_path, device=device)
  88. # Sample matches for estimation
  89. matches, certainty = roma_model.sample(warp, certainty)
  90. # Convert to pixel coordinates (RoMa produces matches in [-1,1]x[-1,1])
  91. kptsA, kptsB = roma_model.to_pixel_coordinates(matches, H_A, W_A, H_B, W_B)
  92. # Find a fundamental matrix (or anything else of interest)
  93. F, mask = cv2.findFundamentalMat(
  94. kptsA.cpu().numpy(), kptsB.cpu().numpy(), ransacReprojThreshold=0.2, method=cv2.USAC_MAGSAC, confidence=0.999999, maxIters=10000
  95. )
  96. ```
  97. **New**: You can also match arbitrary keypoints with RoMa. See [match_keypoints](romatch/models/matcher.py) in RegressionMatcher.
  98. ## Settings
  99. ### Resolution
  100. By default RoMa uses an initial resolution of (560,560) which is then upsampled to (864,864).
  101. You can change this at construction (see roma_outdoor kwargs).
  102. You can also change this later, by changing the roma_model.w_resized, roma_model.h_resized, and roma_model.upsample_res.
  103. ### Sampling
  104. roma_model.sample_thresh controls the thresholding used when sampling matches for estimation. In certain cases a lower or higher threshold may improve results.
  105. ## Reproducing Results
  106. The experiments in the paper are provided in the [experiments folder](experiments).
  107. ### Training
  108. 1. First follow the instructions provided here: https://github.com/Parskatt/DKM for downloading and preprocessing datasets.
  109. 2. Run the relevant experiment, e.g.,
  110. ```bash
  111. torchrun --nproc_per_node=4 --nnodes=1 --rdzv_backend=c10d experiments/roma_outdoor.py
  112. ```
  113. ### Testing
  114. ```bash
  115. python experiments/roma_outdoor.py --only_test --benchmark mega-1500
  116. ```
  117. ## License
  118. All our code except DINOv2 is MIT license.
  119. DINOv2 has an Apache 2 license [DINOv2](https://github.com/facebookresearch/dinov2/blob/main/LICENSE).
  120. ## Acknowledgement
  121. Our codebase builds on the code in [DKM](https://github.com/Parskatt/DKM).
  122. ## Tiny RoMa
  123. If you find that RoMa is too heavy, you might want to try Tiny RoMa which is built on top of XFeat.
  124. ```python
  125. from romatch import tiny_roma_v1_outdoor
  126. tiny_roma_model = tiny_roma_v1_outdoor(device=device)
  127. ```
  128. Mega1500:
  129. | | AUC@5 | AUC@10 | AUC@20 |
  130. |----------|----------|----------|----------|
  131. | XFeat | 46.4 | 58.9 | 69.2 |
  132. | XFeat* | 51.9 | 67.2 | 78.9 |
  133. | Tiny RoMa v1 | 56.4 | 69.5 | 79.5 |
  134. | RoMa | - | - | - |
  135. Mega-8-Scenes (See DKM):
  136. | | AUC@5 | AUC@10 | AUC@20 |
  137. |----------|----------|----------|----------|
  138. | XFeat | - | - | - |
  139. | XFeat* | 50.1 | 64.4 | 75.2 |
  140. | Tiny RoMa v1 | 57.7 | 70.5 | 79.6 |
  141. | RoMa | - | - | - |
  142. IMC22 :'):
  143. | | mAA@10 |
  144. |----------|----------|
  145. | XFeat | 42.1 |
  146. | XFeat* | - |
  147. | Tiny RoMa v1 | 42.2 |
  148. | RoMa | - |
  149. ## Reproducibility
  150. There are a few diffs in the current codebase compared to the original repo used to run experiments.
  151. 1. The `scale_factor` used in the `match` method now is relative to the original training resolution of `560`. Previosly it was based on the set coarse resolution (which might or might not be `560`).
  152. 2. Newer PyTorch, original code used something like `2.1`.
  153. 3. Stochastic eval: both RANSAC and the chosen correspondences can affect results in `Mega1500`.
  154. 4. Matrix inverse in GP has been replaced with cholesky decomp.
  155. That being said, if diff of results are $>0.5$ there probably is something wrong, please let me know.
  156. ## BibTeX
  157. If you find our models useful, please consider citing our paper!
  158. ```
  159. @inproceedings{edstedt2024roma,
  160. title={{RoMa: Robust Dense Feature Matching}},
  161. author={Edstedt, Johan and Sun, Qiyu and Bökman, Georg and Wadenbäck, Mårten and Felsberg, Michael},
  162. booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
  163. year={2024}
  164. }
  165. ```