$ show cvg/LightGlue
LightGlue is a PyTorch library for local feature matching between image pairs. It implements a deep neural network that takes sparse keypoints and descriptors (extracted by models like SuperPoint, DISK, ALIKED, or SIFT) and outputs correspondences. The architecture uses stacked self- and cross-attention transformer layers with adaptive pruning (width and depth) for speed, achieving state-of-the-art accuracy at high throughput. The repository provides pretrained weights, a benchmark script, and a demo notebook. It is designed for inference only; training code is in a separate repository (glue-factory). The code is well-structured, with clean separation between feature extractors, the matcher, and utility functions. It supports FlashAttention and PyTorch compilation for performance.
The LLM identified 2 files worth highlighting for reuse:
Provides reusable building blocks for computer vision pipelines: an ImagePreprocessor class for resizing/normalizing images, an Extractor base class that standardizes feature extraction (with online resizing and batch handling), a match_pair convenience function, and image loading utilities (load_image, read_image). These are self-contained, import only standard libraries (numpy, cv2, torch, kornia), and can be extracted into any vision project with minimal modification.
A set of 2D visualization primitives for plotting images, keypoints, and matches using Matplotlib. Includes custom colormaps (e.g., gradient-based for matches, pruning depth) and functions like plot_images, plot_keypoints, plot_matches, add_text, save_plot. It is independent of the rest of the codebase (only imports matplotlib, numpy, torch) and can be reused in any project requiring visual debugging of feature matching results.