# cvg/lightglue architecture

> Architecture diagram of the GitHub repository cvg/lightglue, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cvg/lightglue
- Repository: https://github.com/cvg/lightglue

## Overview

LightGlue is an inference library for matching sparse local features between two images. The main workflow loads images, extracts keypoints and descriptors with a selected feature backend, then passes both feature sets to the matcher, which returns corresponding-point indices and scores. The README documents SuperPoint, DISK, ALIKED, SIFT, and a convenience pair-matching API; the tree also includes DoGHardNet and visualization helpers. The matcher’s adaptive attention and pruning are implemented in its module. Some backend details and internal call paths were not sampled, so those relationships are omitted.

Main entry points: [`lightglue/utils.py`](https://github.com/cvg/lightglue/blob/main/lightglue/utils.py) (Extractor preprocessing), [`lightglue/lightglue.py`](https://github.com/cvg/lightglue/blob/main/lightglue/lightglue.py) (LightGlue matcher), [`lightglue/sift.py`](https://github.com/cvg/lightglue/blob/main/lightglue/sift.py) (SIFT), [`lightglue/superpoint.py`](https://github.com/cvg/lightglue/blob/main/lightglue/superpoint.py) (SuperPoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input helpers"]
  node_image_helpers["Image utilities<br/>[utils.py]"]
  node_extractor_base["Extractor preprocessing<br/>[utils.py]"]
  node_pair_api["Pair matching API<br/>[utils.py]"]
end

subgraph group_extractors["Feature extraction"]
  node_superpoint["SuperPoint<br/>[superpoint.py]"]
  node_disk["DISK<br/>[disk.py]"]
  node_aliked["ALIKED<br/>[aliked.py]"]
  node_sift["SIFT<br/>[sift.py]"]
  node_doghardnet["DoGHardNet<br/>[dog_hardnet.py]"]
end

subgraph group_matching["Feature matching"]
  node_matcher["LightGlue matcher<br/>[lightglue.py]"]
end

subgraph group_visualization["Visualization"]
  node_viz["2D visualization<br/>[viz2d.py]"]
end

node_user(("Application user"))
node_matches["Match results"]

node_user -->|"loads images"| node_image_helpers
node_image_helpers -->|"returns tensors"| node_user
node_user -->|"selects extractor"| node_extractor_base
node_extractor_base -->|"preprocesses input"| node_superpoint
node_extractor_base -->|"preprocesses input"| node_disk
node_extractor_base -->|"preprocesses input"| node_aliked
node_extractor_base -->|"preprocesses input"| node_sift
node_sift -->|"provides detections"| node_doghardnet
node_user -->|"calls convenience API"| node_pair_api
node_pair_api -->|"invokes matcher"| node_matcher
node_user -->|"supplies feature pairs"| node_matcher
node_matcher -->|"returns correspondences"| node_matches
node_user -.->|"plots matches"| node_viz

click node_image_helpers "https://github.com/cvg/lightglue/blob/main/lightglue/utils.py"
click node_extractor_base "https://github.com/cvg/lightglue/blob/main/lightglue/utils.py"
click node_superpoint "https://github.com/cvg/lightglue/blob/main/lightglue/superpoint.py"
click node_disk "https://github.com/cvg/lightglue/blob/main/lightglue/disk.py"
click node_aliked "https://github.com/cvg/lightglue/blob/main/lightglue/aliked.py"
click node_sift "https://github.com/cvg/lightglue/blob/main/lightglue/sift.py"
click node_doghardnet "https://github.com/cvg/lightglue/blob/main/lightglue/dog_hardnet.py"
click node_matcher "https://github.com/cvg/lightglue/blob/main/lightglue/lightglue.py"
click node_pair_api "https://github.com/cvg/lightglue/blob/main/lightglue/utils.py"
click node_viz "https://github.com/cvg/lightglue/blob/main/lightglue/viz2d.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_image_helpers,node_extractor_base,node_pair_api,node_user toneBlue
class node_superpoint,node_disk,node_aliked,node_sift,node_doghardnet toneAmber
class node_matcher toneMint
class node_viz toneRose
class node_matches toneIndigo
```

## Components

### Input helpers

- [Image utilities](https://github.com/cvg/lightglue/blob/main/lightglue/utils.py): `lightglue/utils.py`
- [Extractor preprocessing](https://github.com/cvg/lightglue/blob/main/lightglue/utils.py): `lightglue/utils.py`
- [Pair matching API](https://github.com/cvg/lightglue/blob/main/lightglue/utils.py): `lightglue/utils.py`

### Feature extraction

- [SuperPoint](https://github.com/cvg/lightglue/blob/main/lightglue/superpoint.py): `lightglue/superpoint.py`
- [DISK](https://github.com/cvg/lightglue/blob/main/lightglue/disk.py): `lightglue/disk.py`
- [ALIKED](https://github.com/cvg/lightglue/blob/main/lightglue/aliked.py): `lightglue/aliked.py`
- [SIFT](https://github.com/cvg/lightglue/blob/main/lightglue/sift.py): `lightglue/sift.py`
- [DoGHardNet](https://github.com/cvg/lightglue/blob/main/lightglue/dog_hardnet.py): `lightglue/dog_hardnet.py`

### Feature matching

- [LightGlue matcher](https://github.com/cvg/lightglue/blob/main/lightglue/lightglue.py): `lightglue/lightglue.py`

### Visualization

- [2D visualization](https://github.com/cvg/lightglue/blob/main/lightglue/viz2d.py): `lightglue/viz2d.py`

### Other components

- **Application user**
- **Match results**

## Connections

- Application user → Image utilities: loads images (evidence: `README.md`)
- Image utilities → Application user: returns tensors (evidence: `lightglue/utils.py`)
- Application user → Extractor preprocessing: selects extractor (evidence: `README.md`)
- Extractor preprocessing → SuperPoint: preprocesses input (evidence: `lightglue/superpoint.py`)
- Extractor preprocessing → DISK: preprocesses input (evidence: `lightglue/disk.py`)
- Extractor preprocessing → ALIKED: preprocesses input (evidence: `lightglue/aliked.py`)
- Extractor preprocessing → SIFT: preprocesses input (evidence: `lightglue/sift.py`)
- SIFT → DoGHardNet: provides detections (evidence: `lightglue/dog_hardnet.py`)
- Application user → Pair matching API: calls convenience API (evidence: `README.md`)
- Pair matching API → LightGlue matcher: invokes matcher (evidence: `lightglue/utils.py`)
- Application user → LightGlue matcher: supplies feature pairs (evidence: `README.md`)
- LightGlue matcher → Match results: returns correspondences (evidence: `README.md`)
- Application user → 2D visualization: plots matches
