explaingit

cvg/lightglue

4,521PythonAudience · developerComplexity · 3/5Setup · easy

TLDR

LightGlue is a neural network that matches keypoints between two photos, useful for stitching panoramas, estimating camera position, or building 3D scenes. It adapts its compute to each image pair, running fast on easy pairs and doing more work on harder ones.

Mindmap

mindmap
  root((LightGlue))
    Matching
      Keypoint pairs
      Attention network
      Adaptive early exit
    Feature Detectors
      SuperPoint
      DISK
      ALIKED
      SIFT
    Use Cases
      Panorama stitching
      3D reconstruction
      Camera pose estimation
    Performance
      GPU 150 fps
      CPU 20 fps
      Tunable thresholds
    Setup
      pip install
      HuggingFace support
      Pretrained weights
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Stitch multiple photos into a seamless panorama by finding matching points across overlapping images.

USE CASE 2

Figure out where a camera was positioned when a photo was taken by matching it against other known images.

USE CASE 3

Reconstruct a 3D model of a place or object from a collection of photos taken at different angles.

USE CASE 4

Build visual search or object recognition pipelines that need to find the same scene across different photos.

Tech stack

PythonPyTorchHugging Face TransformersSuperPointDISKALIKEDSIFT

Getting it running

Difficulty · easy Time to first run · 30min

Install via pip and load pretrained weights from Hugging Face. Pick a feature detector (SuperPoint, DISK, ALIKED, or SIFT), run it on your images, then pass results to LightGlue. Training requires the separate glue-factory repo.

License not mentioned in the explanation.

In plain English

LightGlue is a deep neural network that figures out which points in one photo correspond to which points in another photo of the same scene. Given two images, it takes a set of detected keypoints and their descriptors from each image, runs them through an attention-based network, and returns matched pairs of points. This kind of matching is a building block for tasks like estimating camera position, stitching panoramas, or reconstructing 3D scenes from multiple photos. What makes LightGlue stand out is its adaptive design. For easy image pairs with clear overlap and good lighting, the network stops early and returns fast. For harder pairs, it runs through more layers and does more work. This means it uses only as much compute as each specific pair actually needs, rather than applying full processing to everything regardless of difficulty. The project ships pretrained weights for use with four feature detectors: SuperPoint, DISK, ALIKED, and SIFT. You choose the detector that fits your use case, run it on both images to extract features, then feed those features into LightGlue to get the matches. It also integrates with Hugging Face Transformers, so a basic setup requires just a pip install and a few lines of Python. Speed can be tuned through configuration. Lowering the adaptive thresholds makes it faster with a small accuracy trade-off. Disabling adaptivity entirely maximizes accuracy. With PyTorch compilation on a modern GPU, it reaches around 150 frames per second at 1024 keypoints per image, and around 20 frames per second on CPU at 512 keypoints. This repository contains only the inference code. Training and evaluation require the companion library called glue-factory, which is a separate project by the same team.

Copy-paste prompts

Prompt 1
I have two photos of the same building taken from different angles. Using LightGlue with SuperPoint, write Python code to extract keypoints from both images and find matching point pairs.
Prompt 2
Explain how LightGlue's adaptive early-exit works and how I can tune the threshold settings to prioritize speed over accuracy for my real-time application.
Prompt 3
Write a Python example that loads LightGlue from Hugging Face Transformers, runs it on two images using SIFT features, and prints the number of matched keypoints found.
Prompt 4
What is the difference between using LightGlue with SuperPoint versus DISK versus ALIKED? Help me choose the right feature detector for outdoor daylight photos.
Prompt 5
I want to stitch 5 photos into a panorama. How do I use LightGlue to find the matching points between consecutive image pairs, and what do I do with those matches next?
Open on GitHub → Explain another repo

← cvg on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.