Update README.m with feedback
Browse files
README.md
CHANGED
|
@@ -3,7 +3,8 @@ license: apache-2.0
|
|
| 3 |
library_name: superpoint-pruned
|
| 4 |
tags:
|
| 5 |
- SuperPoint
|
| 6 |
-
-
|
|
|
|
| 7 |
- pruned
|
| 8 |
- pytorch
|
| 9 |
- onnx
|
|
@@ -38,11 +39,11 @@ pipeline_tag: keypoint-detection
|
|
| 38 |
Optimized from SuperPoint
|
| 39 |
</h3>
|
| 40 |
|
| 41 |
-
|
| 42 |
</div>
|
| 43 |
|
| 44 |
**SuperPoint Pruned is an optimization of the SuperPoint (SP) keypoint detection model. Based on [rpautrat/SuperPoint](https://github.com/rpautrat/SuperPoint) by Rémi Pautrat and Paul-Edouard Sarlin. Optimized for the TensorRT runtime on Jetson Orin Nano devices, but also applicable to other runtime backends. The ideas used can be applied to other similar network architectures.**
|
| 45 |
|
|
|
|
| 46 |
|
| 47 |
## Example
|
| 48 |
|
|
@@ -121,115 +122,126 @@ Although there are relatively few exact overlaps, many predictions lie very clos
|
|
| 121 |
|
| 122 |
</details>
|
| 123 |
|
| 124 |
-
|
| 125 |
## Quickstart
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
pip install -r requirements.txt
|
| 130 |
pip install -e .
|
| 131 |
```
|
|
|
|
| 132 |
To install the base dataset images (UZH FPV Indoor forward facing trace #3) used for training to the default path `src/superpoint_pruning/distillation/data`, run:
|
| 133 |
-
|
|
|
|
| 134 |
superpoint-pruning setup
|
| 135 |
```
|
|
|
|
| 136 |
Alternatively, specify the desired trace download link with the `--download-url` flag, e.g., the one for the UZH FPV Outdoor forward facing trace #1, and the local dataset directory name with `--output-dir-name`.
|
| 137 |
|
| 138 |
-
|
|
|
|
| 139 |
The base PyTorch Lightning training config that we used to produce the `pruned` model can be found under `src/superpoint_pruning/distillation/base_config.yaml`.
|
| 140 |
Since this includes the hyperparameters and the data setup used for our training, then this should allow to reproduce the trained checkpoint that is provided under `src/superpoint_pruning/weights/16_16_24_32_64.ckpt`. The training script itself is very basic but can serve as a starting point for further experiments.
|
| 141 |
To replicate the training, assuming that the main Indoor data trace is installed in the previous, run:
|
| 142 |
-
|
|
|
|
| 143 |
superpoint-pruning setup --generate-gt
|
| 144 |
superpoint-pruning train
|
| 145 |
```
|
|
|
|
| 146 |
The first command computes and presaves the target keypoint and descriptor feature maps and the other initiate the Lightning training script.
|
| 147 |
|
| 148 |
-
|
|
|
|
| 149 |
The first row of quality evaluation results can be reproduced using the following commands corresponding to the different target models:
|
| 150 |
-
|
|
|
|
| 151 |
superpoint-pruning evaluate
|
| 152 |
superpoint-pruning evaluate --hierarchical
|
| 153 |
superpoint-pruning evaluate --backbone_0_1 32 --hierarchical
|
| 154 |
superpoint-pruning evaluate --pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt --hierarchical
|
| 155 |
superpoint-pruning evaluate --pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt --hierarchical --skip-refinement
|
| 156 |
```
|
|
|
|
| 157 |
Note that in this script and other similar ones, we can define the pruning either with format `--backbone_x_y new_input_channel_size` or by pointing it to a ckpt file named in the format `a_b_...ckpt`, which is translated to `--backbone_0_1 a`, `--backbone_1_0 b` and so on.
|
| 158 |
For the evaluation using the outdoor trace (or some other trace), the `--image-dir` parameter has to be specified including the other specific options to use the same image range (`--no-skip --start-idx 1000 --end-idx 1500`).
|
| 159 |
|
| 160 |
-
|
| 161 |
|
| 162 |
-
For a quick keypoint prediction
|
| 163 |
-
|
|
|
|
| 164 |
superpoint-pruning plot --image-name image_1_1200.png --output ./test.png --num-keypoints 512 --pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt --overlay
|
| 165 |
```
|
|
|
|
| 166 |
This once again defaults to the UZH FPV Indoor forward facing trace #3 and accepts file names from the dataset.
|
| 167 |
|
| 168 |
-
|
|
|
|
| 169 |
To export the desired PyTorch model to ONNX:
|
| 170 |
-
|
|
|
|
| 171 |
superpoint-pruning export --backbone_0_1 32
|
| 172 |
```
|
|
|
|
| 173 |
The model pruning configuration can once again be controlled with same flags as shown in the evaluation example.
|
| 174 |
As an example, we have published the ONNX export of the `original` model to https://huggingface.co/EclipseAidge/SuperPoint.
|
| 175 |
|
| 176 |
-
|
|
|
|
| 177 |
In case the device supports TensorRT (with the necessary packages installed) and there is a serialized TRT model (here a dummy example of `superpoint.engine`), then the local python benchmark with a TRT wrapper can be run as:
|
| 178 |
-
|
|
|
|
| 179 |
superpoint-pruning benchmark --model-path superpoint.engine
|
| 180 |
```
|
| 181 |
-
|
| 182 |
-
## Limitations
|
| 183 |
-
|
| 184 |
-
- Other popular SuperPoint implementations exist, especially versions paired with matchers such as LightGlue. This repository does not use them because of their restrictive licenses. The work is meant to show that SuperPoint-like models can be pruned and distilled. You can apply the same methods to those implementations after the necessary structural changes and a distillation run with your configs.
|
| 185 |
-
- The right way to judge a pruned SuperPoint is to test it in the intended downstream task and see if it still retains performance. We don't explore it here since we are not currently looking at a specific task.
|
| 186 |
-
- Distillation used 250 frames from [UZH-FPV Indoor forward facing trace #3](http://rpg.ifi.uzh.ch/datasets/uzh-fpv-newer-versions/v3/indoor_forward_3_snapdragon_with_gt.zip) (767 eval images). Direct training images were excluded from evaluation, but results may still be biased because the frames are sequential video frames. Outdoor forward-facing trace #1 was not used for recovery training.
|
| 187 |
-
- Skipping NMS refinement usually still produces sensible keypoints, but that depends on the task.
|
| 188 |
-
|
| 189 |
-
## License
|
| 190 |
-
|
| 191 |
-
This repository is licensed under the **Apache License 2.0**.
|
| 192 |
-
|
| 193 |
-
### Third-party Attributions
|
| 194 |
-
|
| 195 |
-
- **SuperPoint implementation and weights** — Rémi Pautrat and Paul-Edouard Sarlin, [rpautrat/SuperPoint](https://github.com/rpautrat/SuperPoint).
|
| 196 |
-
- **SuperPoint method** — Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich, *SuperPoint: Self-Supervised Interest Point Detection and Description*, CVPR Workshops, 2018.
|
| 197 |
-
- **UZH-FPV dataset** — Jeffrey Delmerico, Titus Cieslewski, Henri Rebecq, Matthias Faessler, and Davide Scaramuzza, *Are We Ready for Autonomous Drone Racing? The UZH-FPV Drone Racing Dataset*, ICRA, 2019. [Dataset](https://fpv.ifi.uzh.ch/)
|
| 198 |
-
|
| 199 |
-
## What's next?
|
| 200 |
-
|
| 201 |
-
- **Experiment with Superpoint Pruned for more efficiency**
|
| 202 |
-
- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a ⭐️ for more efficiency!
|
| 203 |
-
- Want to use our optimized video model right away? Check
|
| 204 |
-
[P-Video-2](https://www.pruna.ai/p-video-2) and
|
| 205 |
-
[P-Video-2 documentation](https://docs.pruna.ai/en/stable/docs_pruna_endpoints/performance_models/p-video-2.html).
|
| 206 |
-
|
| 207 |
-
<style>
|
| 208 |
-
.model-button {
|
| 209 |
-
display: inline-flex;
|
| 210 |
-
flex-direction: row;
|
| 211 |
-
justify-content: center;
|
| 212 |
-
align-items: center;
|
| 213 |
-
gap: 8px;
|
| 214 |
-
|
| 215 |
-
padding: 8px 20px;
|
| 216 |
-
border: none;
|
| 217 |
-
border-radius: 8px;
|
| 218 |
-
|
| 219 |
-
background: #9334e9;
|
| 220 |
-
color: #ffffff;
|
| 221 |
-
|
| 222 |
-
font-size: 14px;
|
| 223 |
-
font-weight: 400;
|
| 224 |
-
line-height: 1;
|
| 225 |
-
text-decoration: none;
|
| 226 |
-
white-space: nowrap;
|
| 227 |
-
cursor: pointer;
|
| 228 |
-
|
| 229 |
-
box-sizing: border-box;
|
| 230 |
-
overflow: visible;
|
| 231 |
-
opacity: 1;
|
| 232 |
-
}
|
| 233 |
-
</style>
|
| 234 |
-
|
| 235 |
-
<a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=model_card&utm_campaign=hf_traffic" class="model-button">Try our models</a>
|
|
|
|
| 3 |
library_name: superpoint-pruned
|
| 4 |
tags:
|
| 5 |
- SuperPoint
|
| 6 |
+
- vision
|
| 7 |
+
- image-matching
|
| 8 |
- pruned
|
| 9 |
- pytorch
|
| 10 |
- onnx
|
|
|
|
| 39 |
Optimized from SuperPoint
|
| 40 |
</h3>
|
| 41 |
|
|
|
|
| 42 |
</div>
|
| 43 |
|
| 44 |
**SuperPoint Pruned is an optimization of the SuperPoint (SP) keypoint detection model. Based on [rpautrat/SuperPoint](https://github.com/rpautrat/SuperPoint) by Rémi Pautrat and Paul-Edouard Sarlin. Optimized for the TensorRT runtime on Jetson Orin Nano devices, but also applicable to other runtime backends. The ideas used can be applied to other similar network architectures.**
|
| 45 |
|
| 46 |
+
This work was done in collaboration with CEA ([Aidge](https://eclipse.dev/aidge/)) for the [DeepGreen](https://deepgreen.ai/) project. You can also find a pruning tutorial for SuperPoint using Aidge operators in the [Aidge codebase](https://gitlab.eclipse.org/eclipse/aidge/aidge/-/tree/main/examples/tutorials/SuperPoint_pruning_tutorial).
|
| 47 |
|
| 48 |
## Example
|
| 49 |
|
|
|
|
| 122 |
|
| 123 |
</details>
|
| 124 |
|
|
|
|
| 125 |
## Quickstart
|
| 126 |
|
| 127 |
+
Install the required dependencies and the package in editable mode:
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
pip install -r requirements.txt
|
| 131 |
+
pip install -e .
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
Download the default dataset, **UZH FPV Indoor forward-facing trace #3**, to `src/superpoint_pruning/distillation/data`:
|
| 135 |
+
|
| 136 |
+
```bash
|
| 137 |
+
superpoint-pruning setup
|
| 138 |
```
|
| 139 |
+
|
| 140 |
+
Compare the keypoint predictions from the pruned model against the original SuperPoint model on an image:
|
| 141 |
+
|
| 142 |
+
```bash
|
| 143 |
+
superpoint-pruning plot \
|
| 144 |
+
--image-name image_1_1200.png \
|
| 145 |
+
--output ./test.png \
|
| 146 |
+
--num-keypoints 512 \
|
| 147 |
+
--pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt \
|
| 148 |
+
--overlay
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
The resulting comparison is written to `./test.png`. To run the distillation and evaluation scripts, see the [Annex: Run your own distillation and compare inference time](#annex-run-your-own-distillation-and-compare-inference-time) section.
|
| 152 |
+
|
| 153 |
+
## Limitations
|
| 154 |
+
|
| 155 |
+
- Other popular SuperPoint implementations exist, especially versions paired with matchers such as LightGlue. This repository does not use them because of their restrictive licenses. The work is meant to show that SuperPoint-like models can be pruned and distilled. You can apply the same methods to those implementations after the necessary structural changes and a distillation run with your configs.
|
| 156 |
+
- The right way to judge a pruned SuperPoint is to test it in the intended downstream task and see if it still retains performance. We don't explore it here since we are not currently looking at a specific task.
|
| 157 |
+
- Distillation used 250 frames from [UZH-FPV Indoor forward facing trace #3](http://rpg.ifi.uzh.ch/datasets/uzh-fpv-newer-versions/v3/indoor_forward_3_snapdragon_with_gt.zip) (767 eval images). Direct training images were excluded from evaluation, but results may still be biased because the frames are sequential video frames. Outdoor forward-facing trace #1 was not used for recovery training.
|
| 158 |
+
- Skipping NMS refinement usually still produces sensible keypoints, but that depends on the task.
|
| 159 |
+
|
| 160 |
+
## License
|
| 161 |
+
|
| 162 |
+
This repository is licensed under the **Apache License 2.0**.
|
| 163 |
+
|
| 164 |
+
### Third-party Attributions
|
| 165 |
+
|
| 166 |
+
- **SuperPoint implementation and weights** — Rémi Pautrat and Paul-Edouard Sarlin, [rpautrat/SuperPoint](https://github.com/rpautrat/SuperPoint).
|
| 167 |
+
- **SuperPoint method** — Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich, *SuperPoint: Self-Supervised Interest Point Detection and Description*, CVPR Workshops, 2018.
|
| 168 |
+
- **UZH-FPV dataset** — Jeffrey Delmerico, Titus Cieslewski, Henri Rebecq, Matthias Faessler, and Davide Scaramuzza, *Are We Ready for Autonomous Drone Racing? The UZH-FPV Drone Racing Dataset*, ICRA, 2019. [Dataset](https://fpv.ifi.uzh.ch/)
|
| 169 |
+
|
| 170 |
+
## What's next?
|
| 171 |
+
|
| 172 |
+
- Experiment with SuperPoint Pruned for computer vision, drone, and edge-device workloads
|
| 173 |
+
- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a ⭐️
|
| 174 |
+
|
| 175 |
+
## Annex: Run your own distillation and compare inference time
|
| 176 |
+
|
| 177 |
+
For installing the package with dependencies for running the basic distillation, evaluation, and export scripts, run:
|
| 178 |
+
|
| 179 |
+
```bash
|
| 180 |
pip install -r requirements.txt
|
| 181 |
pip install -e .
|
| 182 |
```
|
| 183 |
+
|
| 184 |
To install the base dataset images (UZH FPV Indoor forward facing trace #3) used for training to the default path `src/superpoint_pruning/distillation/data`, run:
|
| 185 |
+
|
| 186 |
+
```bash
|
| 187 |
superpoint-pruning setup
|
| 188 |
```
|
| 189 |
+
|
| 190 |
Alternatively, specify the desired trace download link with the `--download-url` flag, e.g., the one for the UZH FPV Outdoor forward facing trace #1, and the local dataset directory name with `--output-dir-name`.
|
| 191 |
|
| 192 |
+
### Run distillation training
|
| 193 |
+
|
| 194 |
The base PyTorch Lightning training config that we used to produce the `pruned` model can be found under `src/superpoint_pruning/distillation/base_config.yaml`.
|
| 195 |
Since this includes the hyperparameters and the data setup used for our training, then this should allow to reproduce the trained checkpoint that is provided under `src/superpoint_pruning/weights/16_16_24_32_64.ckpt`. The training script itself is very basic but can serve as a starting point for further experiments.
|
| 196 |
To replicate the training, assuming that the main Indoor data trace is installed in the previous, run:
|
| 197 |
+
|
| 198 |
+
```bash
|
| 199 |
superpoint-pruning setup --generate-gt
|
| 200 |
superpoint-pruning train
|
| 201 |
```
|
| 202 |
+
|
| 203 |
The first command computes and presaves the target keypoint and descriptor feature maps and the other initiate the Lightning training script.
|
| 204 |
|
| 205 |
+
### Run evaluation
|
| 206 |
+
|
| 207 |
The first row of quality evaluation results can be reproduced using the following commands corresponding to the different target models:
|
| 208 |
+
|
| 209 |
+
```bash
|
| 210 |
superpoint-pruning evaluate
|
| 211 |
superpoint-pruning evaluate --hierarchical
|
| 212 |
superpoint-pruning evaluate --backbone_0_1 32 --hierarchical
|
| 213 |
superpoint-pruning evaluate --pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt --hierarchical
|
| 214 |
superpoint-pruning evaluate --pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt --hierarchical --skip-refinement
|
| 215 |
```
|
| 216 |
+
|
| 217 |
Note that in this script and other similar ones, we can define the pruning either with format `--backbone_x_y new_input_channel_size` or by pointing it to a ckpt file named in the format `a_b_...ckpt`, which is translated to `--backbone_0_1 a`, `--backbone_1_0 b` and so on.
|
| 218 |
For the evaluation using the outdoor trace (or some other trace), the `--image-dir` parameter has to be specified including the other specific options to use the same image range (`--no-skip --start-idx 1000 --end-idx 1500`).
|
| 219 |
|
| 220 |
+
### Plot keypoint comparisons
|
| 221 |
|
| 222 |
+
For a quick keypoint prediction comparison plot between a target model and the original on a specific image, one can for example use:
|
| 223 |
+
|
| 224 |
+
```bash
|
| 225 |
superpoint-pruning plot --image-name image_1_1200.png --output ./test.png --num-keypoints 512 --pruning-config ./src/superpoint_pruning/weights/16_16_24_32_64.ckpt --overlay
|
| 226 |
```
|
| 227 |
+
|
| 228 |
This once again defaults to the UZH FPV Indoor forward facing trace #3 and accepts file names from the dataset.
|
| 229 |
|
| 230 |
+
### Export model to ONNX
|
| 231 |
+
|
| 232 |
To export the desired PyTorch model to ONNX:
|
| 233 |
+
|
| 234 |
+
```bash
|
| 235 |
superpoint-pruning export --backbone_0_1 32
|
| 236 |
```
|
| 237 |
+
|
| 238 |
The model pruning configuration can once again be controlled with same flags as shown in the evaluation example.
|
| 239 |
As an example, we have published the ONNX export of the `original` model to https://huggingface.co/EclipseAidge/SuperPoint.
|
| 240 |
|
| 241 |
+
### Run TRT inference benchmark
|
| 242 |
+
|
| 243 |
In case the device supports TensorRT (with the necessary packages installed) and there is a serialized TRT model (here a dummy example of `superpoint.engine`), then the local python benchmark with a TRT wrapper can be run as:
|
| 244 |
+
|
| 245 |
+
```bash
|
| 246 |
superpoint-pruning benchmark --model-path superpoint.engine
|
| 247 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|