just-matching 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. just_matching-0.1.0/.gitignore +10 -0
  2. just_matching-0.1.0/CMakeLists.txt +352 -0
  3. just_matching-0.1.0/LICENSE +202 -0
  4. just_matching-0.1.0/PKG-INFO +104 -0
  5. just_matching-0.1.0/PLAN.md +1367 -0
  6. just_matching-0.1.0/README.md +215 -0
  7. just_matching-0.1.0/bindings/python/CMakeLists.txt +63 -0
  8. just_matching-0.1.0/bindings/python/README.md +82 -0
  9. just_matching-0.1.0/bindings/python/build_info.py.in +6 -0
  10. just_matching-0.1.0/bindings/python/just_matching/__init__.py +40 -0
  11. just_matching-0.1.0/bindings/python/just_matching/py.typed +0 -0
  12. just_matching-0.1.0/bindings/python/requirements.txt +3 -0
  13. just_matching-0.1.0/bindings/python/src/module.cpp +459 -0
  14. just_matching-0.1.0/bindings/python/tests/test_bindings.py +245 -0
  15. just_matching-0.1.0/cli/main.cpp +390 -0
  16. just_matching-0.1.0/cli/stb_image.h +7798 -0
  17. just_matching-0.1.0/cmake/embed.cmake +25 -0
  18. just_matching-0.1.0/cmake/embed_text.cmake +9 -0
  19. just_matching-0.1.0/include/jmt/jmt.h +185 -0
  20. just_matching-0.1.0/packaging/fetch_cuda.py +102 -0
  21. just_matching-0.1.0/packaging/variant.py +66 -0
  22. just_matching-0.1.0/packaging/version.py +98 -0
  23. just_matching-0.1.0/pyproject.toml +81 -0
  24. just_matching-0.1.0/src/backend/cpu/cpu_ops.cpp +451 -0
  25. just_matching-0.1.0/src/backend/cuda/cuda_ops.cu +2176 -0
  26. just_matching-0.1.0/src/backend/metal/kernels.metal +807 -0
  27. just_matching-0.1.0/src/backend/metal/metal_ops.mm +858 -0
  28. just_matching-0.1.0/src/backend/webgpu/kernels.wgsl +1163 -0
  29. just_matching-0.1.0/src/backend/webgpu/webgpu_ops.cpp +1045 -0
  30. just_matching-0.1.0/src/core/api.cpp +419 -0
  31. just_matching-0.1.0/src/core/api_internal.h +32 -0
  32. just_matching-0.1.0/src/core/assignment.h +102 -0
  33. just_matching-0.1.0/src/core/checkpoint.cpp +474 -0
  34. just_matching-0.1.0/src/core/checkpoint.h +27 -0
  35. just_matching-0.1.0/src/core/half.h +50 -0
  36. just_matching-0.1.0/src/core/ops.cpp +49 -0
  37. just_matching-0.1.0/src/core/ops.h +152 -0
  38. just_matching-0.1.0/src/core/preprocess.h +39 -0
  39. just_matching-0.1.0/src/core/readout.h +58 -0
  40. just_matching-0.1.0/src/core/weights.cpp +198 -0
  41. just_matching-0.1.0/src/core/weights.h +70 -0
  42. just_matching-0.1.0/src/models/flexglue/flexglue.cpp +464 -0
  43. just_matching-0.1.0/src/models/flexglue/flexglue.h +128 -0
  44. just_matching-0.1.0/src/models/lightglue/lightglue.cpp +192 -0
  45. just_matching-0.1.0/src/models/lightglue/lightglue.h +78 -0
  46. just_matching-0.1.0/tests/batch_test.cpp +109 -0
  47. just_matching-0.1.0/tests/checkpoint_test.cpp +69 -0
  48. just_matching-0.1.0/tests/golden_test.cpp +148 -0
  49. just_matching-0.1.0/tests/lightglue_golden_test.cpp +212 -0
  50. just_matching-0.1.0/tests/ops_bench.cpp +70 -0
  51. just_matching-0.1.0/tests/ops_test.cpp +225 -0
  52. just_matching-0.1.0/tests/shortlist_test.cpp +116 -0
  53. just_matching-0.1.0/tools/README.md +51 -0
  54. just_matching-0.1.0/tools/bench.sh +8 -0
  55. just_matching-0.1.0/tools/bench_lightglue_torch.py +61 -0
  56. just_matching-0.1.0/tools/bench_onnx.py +71 -0
  57. just_matching-0.1.0/tools/bench_torch.py +54 -0
  58. just_matching-0.1.0/tools/common.py +123 -0
  59. just_matching-0.1.0/tools/compare.py +105 -0
  60. just_matching-0.1.0/tools/compare_all.sh +18 -0
  61. just_matching-0.1.0/tools/compare_covis.py +70 -0
  62. just_matching-0.1.0/tools/covis.py +175 -0
  63. just_matching-0.1.0/tools/dump_golden.py +62 -0
  64. just_matching-0.1.0/tools/dump_golden_lightglue.py +167 -0
  65. just_matching-0.1.0/tools/dump_golden_lightglue.sh +14 -0
  66. just_matching-0.1.0/tools/export_weights.py +133 -0
  67. just_matching-0.1.0/tools/fetch_jkp_web.sh +46 -0
  68. just_matching-0.1.0/tools/fetch_lightglue.sh +38 -0
  69. just_matching-0.1.0/tools/fetch_upstream.sh +31 -0
  70. just_matching-0.1.0/tools/fetch_webgpu.sh +60 -0
  71. just_matching-0.1.0/tools/folded.py +319 -0
  72. just_matching-0.1.0/tools/jmtfile.py +99 -0
  73. just_matching-0.1.0/tools/presets.py +136 -0
  74. just_matching-0.1.0/tools/remote.sh +20 -0
  75. just_matching-0.1.0/tools/requirements.txt +6 -0
  76. just_matching-0.1.0/tools/upstream.py +59 -0
  77. just_matching-0.1.0/tools/web_testdata.py +105 -0
  78. just_matching-0.1.0/web/demo.html +270 -0
  79. just_matching-0.1.0/web/demo.js +933 -0
  80. just_matching-0.1.0/web/jmt.js +294 -0
  81. just_matching-0.1.0/web/jmt_wasm.cpp +152 -0
  82. just_matching-0.1.0/web/test.html +216 -0
  83. just_matching-0.1.0/weights/LICENSE-DINOv3.md +66 -0
  84. just_matching-0.1.0/weights/LICENSE-FLEXGLUE +21 -0
@@ -0,0 +1,10 @@
1
+ /third_party/
2
+ /build/
3
+ __pycache__/
4
+ *.pyc
5
+ .venv/
6
+ venv/
7
+ .DS_Store
8
+ /weights/*.jmtw
9
+ /docs/_build/
10
+ /docs/.venv/
@@ -0,0 +1,352 @@
1
+ cmake_minimum_required(VERSION 3.16...3.31)
2
+ project(just_matching VERSION 0.1.0 LANGUAGES CXX)
3
+
4
+ option(JMT_BUILD_CLI "Build the jmt command line tool" ON)
5
+ option(JMT_BUILD_TESTS "Build tests" ON)
6
+ option(JMT_BUILD_WASM "Emscripten: build the WebAssembly module, JS wrapper and test page (web/)" ON)
7
+ option(JMT_BUILD_PYTHON "Build the Python bindings (bindings/python; needs nanobind)" OFF)
8
+ # LightGlue's weights (Apache-2.0) can be built into the library: weights/<model>.jmtw, made by
9
+ # tools/export_weights.py --model <model> (47.6 MB each). FlexGlue's never are (DINOv3 License).
10
+ option(JMT_EMBED_WEIGHTS "Build the LightGlue weights of JMT_EMBED_MODELS into the library" OFF)
11
+ set(JMT_EMBED_MODELS "lightglue-aliked;lightglue-raco-aliked" CACHE STRING "Models to embed when JMT_EMBED_WEIGHTS is ON")
12
+ set(JMT_CUDA "AUTO" CACHE STRING "CUDA backend: AUTO (build it when a CUDA compiler is found), ON or OFF")
13
+ set_property(CACHE JMT_CUDA PROPERTY STRINGS AUTO ON OFF)
14
+ set(JMT_METAL "AUTO" CACHE STRING "Metal backend (Apple platforms): AUTO (build it when Metal.framework is found), ON or OFF")
15
+ set_property(CACHE JMT_METAL PROPERTY STRINGS AUTO ON OFF)
16
+ set(JMT_WEBGPU "AUTO" CACHE STRING "WebGPU backend: AUTO (build it when Dawn, or under Emscripten emdawnwebgpu, is found), ON or OFF")
17
+ set_property(CACHE JMT_WEBGPU PROPERTY STRINGS AUTO ON OFF)
18
+
19
+ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20
+ set(CMAKE_BUILD_TYPE Release)
21
+ endif()
22
+ set(CMAKE_CXX_STANDARD 17)
23
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
24
+ set(CMAKE_CXX_EXTENSIONS OFF)
25
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
26
+ if(EMSCRIPTEN)
27
+ # Native wasm exceptions, as just-keypoints' module: the library reports errors with exceptions, and an
28
+ # app links all its libraries into one module with the same setting.
29
+ add_compile_options(-fwasm-exceptions)
30
+ add_link_options(-fwasm-exceptions)
31
+ endif()
32
+
33
+ # CUDA backend: needs only the CUDA toolkit (nvcc and its runtime library).
34
+ if(NOT JMT_CUDA STREQUAL "OFF")
35
+ if(NOT CMAKE_CUDA_COMPILER AND NOT DEFINED ENV{CUDACXX})
36
+ # Toolkit installed but not on PATH (common outside login shells).
37
+ find_program(JMT_NVCC nvcc HINTS ENV CUDA_PATH PATHS /opt/cuda /usr/local/cuda PATH_SUFFIXES bin)
38
+ if(JMT_NVCC)
39
+ set(CMAKE_CUDA_COMPILER "${JMT_NVCC}")
40
+ endif()
41
+ endif()
42
+ include(CheckLanguage)
43
+ check_language(CUDA)
44
+ if(CMAKE_CUDA_COMPILER)
45
+ enable_language(CUDA)
46
+ set(JMT_HAVE_CUDA ON)
47
+ elseif(JMT_CUDA STREQUAL "ON")
48
+ message(FATAL_ERROR "JMT_CUDA=ON but no CUDA compiler was found (set CUDACXX or CMAKE_CUDA_COMPILER)")
49
+ endif()
50
+ endif()
51
+
52
+ # Metal backend: needs only Metal.framework and Foundation. Shaders are compiled at run time, so no Metal
53
+ # toolchain is needed to build.
54
+ if(NOT JMT_METAL STREQUAL "OFF")
55
+ if(APPLE)
56
+ find_library(JMT_METAL_FRAMEWORK Metal)
57
+ find_library(JMT_FOUNDATION_FRAMEWORK Foundation)
58
+ endif()
59
+ if(JMT_METAL_FRAMEWORK AND JMT_FOUNDATION_FRAMEWORK)
60
+ enable_language(OBJCXX)
61
+ set(JMT_HAVE_METAL ON)
62
+ elseif(JMT_METAL STREQUAL "ON")
63
+ message(FATAL_ERROR "JMT_METAL=ON but Metal.framework was not found (Apple platforms only)")
64
+ endif()
65
+ endif()
66
+
67
+ # WebGPU backend: natively against Dawn's prebuilt release, under Emscripten against emdawnwebgpu from the
68
+ # same release. Neither is committed: tools/fetch_webgpu.sh unpacks them under third_party/webgpu, or point
69
+ # JMT_DAWN_DIR / JMT_EMDAWNWEBGPU_DIR elsewhere. Kernels are WGSL, compiled at run time.
70
+ if(NOT JMT_WEBGPU STREQUAL "OFF")
71
+ if(EMSCRIPTEN)
72
+ set(JMT_EMDAWNWEBGPU_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/webgpu/emdawnwebgpu/emdawnwebgpu_pkg"
73
+ CACHE PATH "The unpacked emdawnwebgpu_pkg of a Dawn release")
74
+ if(EXISTS "${JMT_EMDAWNWEBGPU_DIR}/emdawnwebgpu.port.py")
75
+ set(JMT_HAVE_WEBGPU ON)
76
+ endif()
77
+ else()
78
+ file(GLOB jmt_dawn_default "${CMAKE_CURRENT_SOURCE_DIR}/third_party/webgpu/dawn/Dawn-*")
79
+ set(JMT_DAWN_DIR "${jmt_dawn_default}" CACHE PATH "The unpacked Dawn release (with lib/cmake/Dawn)")
80
+ # Dawn's Linux release installs into lib64/, macOS's into lib/.
81
+ find_package(Dawn CONFIG QUIET PATHS "${JMT_DAWN_DIR}/lib/cmake/Dawn" "${JMT_DAWN_DIR}/lib64/cmake/Dawn"
82
+ NO_DEFAULT_PATH)
83
+ if(Dawn_FOUND)
84
+ set(JMT_HAVE_WEBGPU ON)
85
+ endif()
86
+ endif()
87
+ if(NOT JMT_HAVE_WEBGPU AND JMT_WEBGPU STREQUAL "ON")
88
+ message(FATAL_ERROR "JMT_WEBGPU=ON but neither Dawn (JMT_DAWN_DIR) nor, under Emscripten, emdawnwebgpu "
89
+ "(JMT_EMDAWNWEBGPU_DIR) was found")
90
+ endif()
91
+ endif()
92
+
93
+ # FlexGlue's weights are never compiled in (567 MB, and the backbone is under the DINOv3 License): a path or a
94
+ # memory blob is given at run time. LightGlue's can be (JMT_EMBED_WEIGHTS).
95
+ set(embed_models "")
96
+ set(embed_deps "")
97
+ if(JMT_EMBED_WEIGHTS)
98
+ foreach(model IN LISTS JMT_EMBED_MODELS)
99
+ if(NOT model MATCHES "^lightglue-")
100
+ message(FATAL_ERROR "JMT_EMBED_MODELS: only LightGlue models can be built in, not '${model}'")
101
+ endif()
102
+ set(file "${CMAKE_CURRENT_SOURCE_DIR}/weights/${model}.jmtw")
103
+ if(NOT EXISTS "${file}")
104
+ message(FATAL_ERROR "JMT_EMBED_WEIGHTS: ${file} is missing. Make it with "
105
+ "tools/fetch_lightglue.sh && python tools/export_weights.py --model ${model}")
106
+ endif()
107
+ list(APPEND embed_models "${model}=${file}")
108
+ list(APPEND embed_deps "${file}")
109
+ endforeach()
110
+ endif()
111
+ set(embed_cpp "${CMAKE_CURRENT_BINARY_DIR}/embedded_weights.cpp")
112
+ string(REPLACE ";" "|" embed_models_arg "${embed_models}") # a list does not survive the command line
113
+ add_custom_command(
114
+ OUTPUT "${embed_cpp}"
115
+ COMMAND ${CMAKE_COMMAND} "-DOUT=${embed_cpp}" "-DMODELS=${embed_models_arg}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed.cmake"
116
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed.cmake"
117
+ VERBATIM)
118
+ # The generated file names the weights files; #embed reads them when it is compiled.
119
+ set_source_files_properties("${embed_cpp}" PROPERTIES OBJECT_DEPENDS "${embed_deps}")
120
+
121
+ add_library(jmt
122
+ src/core/api.cpp
123
+ src/core/weights.cpp
124
+ src/core/checkpoint.cpp
125
+ src/core/ops.cpp
126
+ src/models/flexglue/flexglue.cpp
127
+ src/models/lightglue/lightglue.cpp
128
+ src/backend/cpu/cpu_ops.cpp
129
+ "${embed_cpp}")
130
+ target_include_directories(jmt PUBLIC include PRIVATE src)
131
+ find_package(Threads REQUIRED)
132
+ target_link_libraries(jmt PRIVATE Threads::Threads)
133
+ if(NOT MSVC)
134
+ target_compile_options(jmt PRIVATE $<$<COMPILE_LANGUAGE:CXX,OBJCXX>:-Wall;-Wextra>)
135
+ endif()
136
+
137
+ set(jmt_backends cpu)
138
+ if(JMT_HAVE_CUDA)
139
+ target_sources(jmt PRIVATE src/backend/cuda/cuda_ops.cu)
140
+ target_compile_definitions(jmt PUBLIC JMT_HAVE_CUDA)
141
+ set_target_properties(jmt PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON)
142
+ list(APPEND jmt_backends cuda cuda:fp16)
143
+ endif()
144
+ if(JMT_HAVE_METAL)
145
+ set(metal_src "${CMAKE_CURRENT_SOURCE_DIR}/src/backend/metal/kernels.metal")
146
+ set(metal_cpp "${CMAKE_CURRENT_BINARY_DIR}/metal_kernels.cpp")
147
+ add_custom_command(
148
+ OUTPUT "${metal_cpp}"
149
+ COMMAND ${CMAKE_COMMAND} "-DIN=${metal_src}" "-DOUT=${metal_cpp}" -DNAME=kJmtMetalSource
150
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_text.cmake"
151
+ DEPENDS "${metal_src}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_text.cmake"
152
+ VERBATIM)
153
+ target_sources(jmt PRIVATE src/backend/metal/metal_ops.mm "${metal_cpp}")
154
+ target_compile_definitions(jmt PUBLIC JMT_HAVE_METAL)
155
+ target_compile_options(jmt PRIVATE $<$<COMPILE_LANGUAGE:OBJCXX>:-fobjc-arc>)
156
+ target_link_libraries(jmt PRIVATE "${JMT_METAL_FRAMEWORK}" "${JMT_FOUNDATION_FRAMEWORK}")
157
+ list(APPEND jmt_backends metal metal:fp16)
158
+ endif()
159
+ if(JMT_HAVE_WEBGPU)
160
+ set(wgsl_src "${CMAKE_CURRENT_SOURCE_DIR}/src/backend/webgpu/kernels.wgsl")
161
+ set(wgsl_cpp "${CMAKE_CURRENT_BINARY_DIR}/webgpu_kernels.cpp")
162
+ add_custom_command(
163
+ OUTPUT "${wgsl_cpp}"
164
+ COMMAND ${CMAKE_COMMAND} "-DIN=${wgsl_src}" "-DOUT=${wgsl_cpp}" -DNAME=kJmtWgslSource
165
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_text.cmake"
166
+ DEPENDS "${wgsl_src}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_text.cmake"
167
+ VERBATIM)
168
+ target_sources(jmt PRIVATE src/backend/webgpu/webgpu_ops.cpp "${wgsl_cpp}")
169
+ target_compile_definitions(jmt PUBLIC JMT_HAVE_WEBGPU)
170
+ if(EMSCRIPTEN)
171
+ # PUBLIC: whatever links jmt into a module needs the port's JavaScript library too.
172
+ target_compile_options(jmt PUBLIC "--use-port=${JMT_EMDAWNWEBGPU_DIR}/emdawnwebgpu.port.py")
173
+ target_link_options(jmt PUBLIC "--use-port=${JMT_EMDAWNWEBGPU_DIR}/emdawnwebgpu.port.py")
174
+ else()
175
+ target_link_libraries(jmt PUBLIC dawn::webgpu_dawn)
176
+ endif()
177
+ list(APPEND jmt_backends webgpu webgpu:fp16)
178
+ endif()
179
+ string(REPLACE ";" ", " jmt_backends_text "${jmt_backends}")
180
+ message(STATUS "jmt backends: ${jmt_backends_text}")
181
+
182
+ # The WebAssembly module (jmt_wasm.js + .wasm) with web/jmt.js and the test page, side by side in
183
+ # <build>/web, ready to serve. Single-threaded; waits for the GPU through JSPI. The weights are not copied:
184
+ # serve them next to it (tools/web_testdata.py writes the test page's data).
185
+ if(EMSCRIPTEN AND JMT_BUILD_WASM)
186
+ add_executable(jmt_wasm web/jmt_wasm.cpp)
187
+ target_include_directories(jmt_wasm PRIVATE src)
188
+ target_link_libraries(jmt_wasm PRIVATE jmt)
189
+ set_target_properties(jmt_wasm PROPERTIES SUFFIX ".js" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/web")
190
+ set(jmtw_exports jmtw_backend_available jmtw_create jmtw_model jmtw_describe jmtw_describe_keypoints jmtw_features_free
191
+ jmtw_finish jmtw_match jmtw_idx
192
+ jmtw_score jmtw_a_in_b jmtw_b_in_a jmtw_conf_a jmtw_conf_b jmtw_covisibility jmtw_stop_layer jmtw_covisibility_level
193
+ jmtw_level1_matrix jmtw_shortlist jmtw_pairs_idx jmtw_pairs_score jmtw_error jmtw_destroy)
194
+ list(TRANSFORM jmtw_exports PREPEND "_" OUTPUT_VARIABLE jmtw_exported)
195
+ string(REPLACE ";" "," jmtw_exported "_malloc,_free,${jmtw_exported}")
196
+ target_link_options(jmt_wasm PRIVATE
197
+ -sJSPI
198
+ "-sJSPI_EXPORTS=jmtw_create,jmtw_describe,jmtw_describe_keypoints,jmtw_finish,jmtw_match,jmtw_covisibility_level,jmtw_level1_matrix,jmtw_shortlist"
199
+ "-sEXPORTED_FUNCTIONS=${jmtw_exported}"
200
+ "-sEXPORTED_RUNTIME_METHODS=HEAPU8,HEAP32,HEAPU32,HEAPF32,UTF8ToString"
201
+ -sMODULARIZE
202
+ -sEXPORT_ES6
203
+ -sEXPORT_NAME=createJmt
204
+ -sENVIRONMENT=web
205
+ -sALLOW_MEMORY_GROWTH
206
+ -sMAXIMUM_MEMORY=4GB
207
+ -sSTACK_SIZE=1MB)
208
+ foreach(f jmt.js test.html demo.html demo.js)
209
+ add_custom_command(TARGET jmt_wasm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
210
+ "${CMAKE_CURRENT_SOURCE_DIR}/web/${f}" "${CMAKE_CURRENT_BINARY_DIR}/web/${f}")
211
+ endforeach()
212
+ add_custom_command(TARGET jmt_wasm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory
213
+ "${CMAKE_CURRENT_SOURCE_DIR}/web/samples" "${CMAKE_CURRENT_BINARY_DIR}/web/samples")
214
+ # LightGlue's weights for the demo, in float16 (24 MB, under the 25 MiB file limit of static hosts):
215
+ # weights/lightglue-aliked-fp16.jmtw, made by `jmt convert aliked_lightglue.pth ... --fp16`.
216
+ set(JMT_DEMO_LIGHTGLUE "${CMAKE_CURRENT_SOURCE_DIR}/weights/lightglue-aliked-fp16.jmtw" CACHE FILEPATH
217
+ "LightGlue weights served next to the demo")
218
+ if(EXISTS "${JMT_DEMO_LIGHTGLUE}")
219
+ add_custom_command(TARGET jmt_wasm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
220
+ "${JMT_DEMO_LIGHTGLUE}" "${CMAKE_CURRENT_BINARY_DIR}/web/lightglue-aliked-fp16.jmtw")
221
+ else()
222
+ message(STATUS "LightGlue weights for the demo not found (${JMT_DEMO_LIGHTGLUE}): the demo will offer FlexGlue only")
223
+ endif()
224
+ # The demo takes its keypoints from just-keypoints' module (jkp.js, jkp_wasm.js, jkp_wasm.wasm; raco.jkpw and
225
+ # aliked-n16.jkpw),
226
+ # copied to web/jkp: by default the one tools/fetch_jkp_web.sh puts in third_party/jkp-web, else the <build>/web
227
+ # of a just-keypoints checkout next to this one; or point JMT_JKP_WEB_DIR at another.
228
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/jkp-web/jkp_wasm.wasm")
229
+ set(jmt_jkp_default "${CMAKE_CURRENT_SOURCE_DIR}/third_party/jkp-web")
230
+ else()
231
+ set(jmt_jkp_default "${CMAKE_CURRENT_SOURCE_DIR}/../just-keypoints/build/wasm/web")
232
+ endif()
233
+ set(JMT_JKP_WEB_DIR "${jmt_jkp_default}" CACHE PATH "just-keypoints' built WebAssembly module, for the demo")
234
+ if(EXISTS "${JMT_JKP_WEB_DIR}/jkp_wasm.wasm")
235
+ foreach(f jkp.js jkp_wasm.js jkp_wasm.wasm raco.jkpw aliked-n16.jkpw)
236
+ add_custom_command(TARGET jmt_wasm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
237
+ "${JMT_JKP_WEB_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/web/jkp/${f}")
238
+ endforeach()
239
+ else()
240
+ message(STATUS "just-keypoints' module not found in JMT_JKP_WEB_DIR (${JMT_JKP_WEB_DIR}): the demo will lack keypoints")
241
+ endif()
242
+ endif()
243
+
244
+ if(JMT_BUILD_CLI)
245
+ add_executable(jmt_cli cli/main.cpp)
246
+ set_target_properties(jmt_cli PROPERTIES OUTPUT_NAME jmt)
247
+ target_include_directories(jmt_cli PRIVATE src)
248
+ target_link_libraries(jmt_cli PRIVATE jmt)
249
+ endif()
250
+
251
+ if(JMT_BUILD_TESTS)
252
+ enable_testing()
253
+ add_executable(golden_test tests/golden_test.cpp)
254
+ target_include_directories(golden_test PRIVATE src)
255
+ target_link_libraries(golden_test PRIVATE jmt)
256
+ add_executable(batch_test tests/batch_test.cpp)
257
+ target_include_directories(batch_test PRIVATE src)
258
+ target_link_libraries(batch_test PRIVATE jmt)
259
+ add_executable(lightglue_golden_test tests/lightglue_golden_test.cpp)
260
+ target_include_directories(lightglue_golden_test PRIVATE src)
261
+ target_link_libraries(lightglue_golden_test PRIVATE jmt)
262
+ add_executable(shortlist_test tests/shortlist_test.cpp)
263
+ target_include_directories(shortlist_test PRIVATE src)
264
+ target_link_libraries(shortlist_test PRIVATE jmt)
265
+ # Each operation of every GPU backend against the CPU backend; needs no weights or golden files.
266
+ add_executable(ops_test tests/ops_test.cpp)
267
+ target_include_directories(ops_test PRIVATE src)
268
+ target_link_libraries(ops_test PRIVATE jmt)
269
+ # flexglue.pth read by the library against the file tools/export_weights.py made from it.
270
+ add_executable(checkpoint_test tests/checkpoint_test.cpp)
271
+ target_include_directories(checkpoint_test PRIVATE src)
272
+ target_link_libraries(checkpoint_test PRIVATE jmt)
273
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flexglue.pth" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/weights/flexglue.jmtw")
274
+ add_test(NAME checkpoint COMMAND checkpoint_test "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flexglue.pth"
275
+ "${CMAKE_CURRENT_SOURCE_DIR}/weights/flexglue.jmtw")
276
+ endif()
277
+ # LightGlue's checkpoints (tools/fetch_lightglue.sh) and, when built in, the embedded copies.
278
+ foreach(model lightglue-aliked lightglue-raco-aliked)
279
+ string(REPLACE "lightglue-" "" pth "${model}")
280
+ string(REPLACE "-" "_" pth "${pth}")
281
+ set(pth "${CMAKE_CURRENT_SOURCE_DIR}/third_party/lightglue-weights/${pth}_lightglue.pth")
282
+ set(jmtw "${CMAKE_CURRENT_SOURCE_DIR}/weights/${model}.jmtw")
283
+ if(EXISTS "${pth}" AND EXISTS "${jmtw}")
284
+ add_test(NAME checkpoint_${model} COMMAND checkpoint_test "${pth}" "${jmtw}")
285
+ endif()
286
+ if(JMT_EMBED_WEIGHTS AND model IN_LIST JMT_EMBED_MODELS)
287
+ add_test(NAME embedded_${model} COMMAND checkpoint_test "embedded:${model}" "${jmtw}")
288
+ endif()
289
+ # jmt convert: the checkpoint to a .jmtw file, which must hold the checkpoint's tensors bit for bit.
290
+ if(TARGET jmt_cli AND EXISTS "${pth}")
291
+ set(converted "${CMAKE_CURRENT_BINARY_DIR}/convert_test_${model}.jmtw")
292
+ add_test(NAME convert_${model}
293
+ COMMAND sh -c "\"$1\" convert \"$2\" \"$3\" && \"$4\" \"$2\" \"$3\"" convert_test
294
+ $<TARGET_FILE:jmt_cli> "${pth}" "${converted}" $<TARGET_FILE:checkpoint_test>)
295
+ endif()
296
+ endforeach()
297
+ add_executable(ops_bench tests/ops_bench.cpp) # timings of single operations, not a test
298
+ target_include_directories(ops_bench PRIVATE src)
299
+ target_link_libraries(ops_bench PRIVATE jmt)
300
+ foreach(backend IN LISTS jmt_backends)
301
+ if(NOT backend STREQUAL "cpu")
302
+ string(REPLACE ":" "_" backend_name "${backend}")
303
+ add_test(NAME ops_${backend_name} COMMAND ops_test ${backend})
304
+ endif()
305
+ endforeach()
306
+ # LightGlue: tools/fetch_lightglue.sh, python tools/export_weights.py --model <model>, then
307
+ # tools/dump_golden_lightglue.sh. Every backend of the build, each GPU one in FP32 and FP16.
308
+ foreach(model lightglue-aliked lightglue-raco-aliked)
309
+ set(jmtw "${CMAKE_CURRENT_SOURCE_DIR}/weights/${model}.jmtw")
310
+ file(GLOB lg_golden "${CMAKE_CURRENT_SOURCE_DIR}/build/golden/${model}/*.jmtt")
311
+ if(EXISTS "${jmtw}")
312
+ foreach(golden IN LISTS lg_golden)
313
+ get_filename_component(name "${golden}" NAME_WLE)
314
+ foreach(backend IN LISTS jmt_backends)
315
+ string(REPLACE ":" "_" backend_name "${backend}")
316
+ add_test(NAME ${model}_${backend_name}_${name} COMMAND lightglue_golden_test "${jmtw}" "${golden}" ${backend})
317
+ endforeach()
318
+ endforeach()
319
+ endif()
320
+ endforeach()
321
+ # The C API end to end through the CLI, with the built-in weights and upstream's adaptive defaults: the
322
+ # original's 219 matches after 7 layers on the Berlin pair (keypoints cached by tools/dump_golden_lightglue.py).
323
+ set(berlin_kpts "${CMAKE_CURRENT_SOURCE_DIR}/build/keypoints/berlin1.jpg.aliked.2048.jkpt"
324
+ "${CMAKE_CURRENT_SOURCE_DIR}/build/keypoints/berlin2.jpg.aliked.2048.jkpt")
325
+ list(GET berlin_kpts 0 berlin_a)
326
+ list(GET berlin_kpts 1 berlin_b)
327
+ if(TARGET jmt_cli AND JMT_EMBED_WEIGHTS AND "lightglue-aliked" IN_LIST JMT_EMBED_MODELS AND EXISTS "${berlin_a}"
328
+ AND EXISTS "${berlin_b}")
329
+ add_test(NAME lightglue_cli_builtin
330
+ COMMAND jmt_cli match --model lightglue-aliked --weights builtin --kpts-a "${berlin_a}" --kpts-b "${berlin_b}")
331
+ set_tests_properties(lightglue_cli_builtin PROPERTIES PASS_REGULAR_EXPRESSION "^219 matches from 2048 and 2048 keypoints, 7 layers")
332
+ endif()
333
+ # Golden files and the weights file are generated locally:
334
+ # python tools/export_weights.py && python tools/dump_golden.py A B
335
+ file(GLOB golden_files "${CMAKE_CURRENT_SOURCE_DIR}/build/golden/*.jmtt")
336
+ foreach(golden IN LISTS golden_files)
337
+ get_filename_component(name "${golden}" NAME_WLE)
338
+ foreach(backend IN LISTS jmt_backends)
339
+ string(REPLACE ":" "_" backend_name "${backend}")
340
+ add_test(NAME golden_${backend_name}_${name}
341
+ COMMAND golden_test "${CMAKE_CURRENT_SOURCE_DIR}/weights/flexglue.jmtw" "${golden}" ${backend})
342
+ add_test(NAME batch_${backend_name}_${name}
343
+ COMMAND batch_test "${CMAKE_CURRENT_SOURCE_DIR}/weights/flexglue.jmtw" "${golden}" ${backend})
344
+ add_test(NAME shortlist_${backend_name}_${name}
345
+ COMMAND shortlist_test "${CMAKE_CURRENT_SOURCE_DIR}/weights/flexglue.jmtw" "${golden}" ${backend})
346
+ endforeach()
347
+ endforeach()
348
+ endif()
349
+
350
+ if(JMT_BUILD_PYTHON)
351
+ add_subdirectory(bindings/python)
352
+ endif()
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: just-matching
3
+ Version: 0.1.0
4
+ Summary: FlexGlue and LightGlue image matching with minimal dependencies: CPU, Metal and CUDA backends
5
+ Keywords: feature matching,LightGlue,FlexGlue,structure from motion,photogrammetry
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Operating System :: Microsoft :: Windows
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: C++
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
16
+ Project-URL: Source, https://github.com/manlito/just-matching
17
+ Requires-Python: >=3.12
18
+ Requires-Dist: numpy>=1.26
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest; extra == "test"
21
+ Description-Content-Type: text/markdown
22
+
23
+ # just-matching
24
+
25
+ FlexGlue and LightGlue image matching in C++ with minimal dependencies, for Python. No PyTorch: the library
26
+ reads the released checkpoints itself and runs on the CPU, on Apple GPUs (Metal) and on NVIDIA GPUs (CUDA).
27
+
28
+ | Package | Platforms | Backends |
29
+ |---|---|---|
30
+ | `just-matching` | Linux x86_64, macOS arm64 (13 or later), Windows x86_64 | CPU; Metal on macOS |
31
+ | `just-matching-cu12` | Linux x86_64, Windows x86_64 | CPU, CUDA 12 (NVIDIA driver R525 or later) |
32
+ | `just-matching-cu13` | Linux x86_64, Windows x86_64 | CPU, CUDA 13 (NVIDIA driver R580 or later) |
33
+
34
+ All three provide the module `just_matching`; install one. The CUDA packages need only the NVIDIA driver (the
35
+ CUDA runtime is built in) and a GPU of compute capability 7.5 (Turing) or later. Python 3.12 or later.
36
+
37
+ ```bash
38
+ pip install just-matching # or just-matching-cu12, just-matching-cu13
39
+ ```
40
+
41
+ ## Weights
42
+
43
+ No weights are in the packages. Download them from their authors and give the file (or its bytes) to `Matcher`;
44
+ the library reads the checkpoints as released, without PyTorch.
45
+
46
+ **LightGlue** for ALIKED descriptors, under the Apache License 2.0 (Computer Vision and Geometry Lab), from
47
+ [LightGlue's v0.1_arxiv release](https://github.com/cvg/LightGlue/releases/tag/v0.1_arxiv):
48
+
49
+ | File | Model | SHA-256 |
50
+ |---|---|---|
51
+ | `aliked_lightglue.pth` | `lightglue-aliked`: ALIKED keypoints and descriptors | `d975e965b105311a6143194852297dff4f02aea5cc2e10cecfed966ca0e22503` |
52
+ | `raco_aliked_lightglue.pth` | `lightglue-raco-aliked`: RaCo keypoints described by ALIKED | `a804c3fe2851cc3c765cda6a9f412845893c8d8e2a3048f848d7f6ba172e6312` |
53
+
54
+ **FlexGlue**: `flexglue.pth` (567 MB) from
55
+ [FlexGlue's v0.1 release](https://github.com/cvg/FlexGlue/releases/tag/v0.1), SHA-256
56
+ `d7371f743b8cdc4adf723c2aa05b181587fe4bc177fced139697975dff790068`. Its matcher and descriptor heads are MIT;
57
+ its backbone is Meta's DINOv3 ConvNeXt-B, under the
58
+ [DINOv3 License](https://github.com/cvg/FlexGlue/blob/main/DINOv3_LICENSE.md), which you accept by using the
59
+ file: read it first. just-matching never distributes these weights.
60
+
61
+ The keypoints and descriptors LightGlue matches come from
62
+ [just-keypoints](https://github.com/manlito/just-keypoints) (`aliked-n16`, alone or describing RaCo's
63
+ keypoints).
64
+
65
+ ## LightGlue
66
+
67
+ ```python
68
+ import just_matching as jmt
69
+
70
+ m = jmt.Matcher("aliked_lightglue.pth") # backend="cuda" or "metal" for the GPU
71
+ a = m.describe_keypoints(width_a, height_a, xy_a, desc_a) # xy (n, 2), desc (n, 128) float32
72
+ b = m.describe_keypoints(width_b, height_b, xy_b, desc_b)
73
+ r = m.match(a, b)
74
+ r.idx # (n, 2) int32: keypoint of a, keypoint of b
75
+ r.score # (n,) in (0, 1]
76
+ ```
77
+
78
+ ## FlexGlue
79
+
80
+ FlexGlue describes whole images once, then matches any keypoints of them and predicts, for every keypoint, where
81
+ it lands in the other image. It also says which pairs of a set are worth matching.
82
+
83
+ ```python
84
+ m = jmt.Matcher("flexglue.pth", backend="cuda", precision="fp16")
85
+ a, b = m.describe(image_a), m.describe(image_b) # uint8 (h, w), (h, w, 3) RGB or (h, w, 4) RGBA
86
+ r = m.match(a, b, xy_a, xy_b)
87
+ r.a_in_b, r.conf_a, r.covisibility
88
+
89
+ features = [m.describe(img) for img in images]
90
+ pairs, scores = m.shortlist(features, k=10, neighbours=2) # (n, 2) image indices, best first
91
+ m.covisibility(a, b, level=2)
92
+ ```
93
+
94
+ `match_batch([(a, b), (c, d, xy_c, xy_d), ...])` matches many pairs in one call (pipelined on a GPU). Options of
95
+ `match` and `match_batch` (`n_layers`, `filter_threshold`, `depth_confidence`, `min_covisibility`, ...) are
96
+ keyword arguments, documented in `help(jmt.Matcher.match)`.
97
+
98
+ Pixel coordinates are those of the original image: x right, y down, (0, 0) the centre of the top-left pixel.
99
+ A `Matcher` is safe to share between threads (calls take turns); separate Matchers run in parallel.
100
+
101
+ `jmt.compiled_backends()` lists the backends of the installed package, `jmt.VARIANT` and `jmt.CUDA_VERSION` say
102
+ which package it is.
103
+
104
+ Licence: Apache-2.0. No weights are in the package; each model's weights carry their own licence (above).