Skip to content

shashankyld/superpoint_pytorch

Repository files navigation

Setup

# 1. Clone the repository
git clone [email protected]:shashankyld/superpoint_pytorch.git
cd superpoint_pytorch

# 2. Sync the environment (Creates .venv and installs all dependencies from uv.lock)
uv sync

# 3. Verify the installation
uv run python -c "import torch; print(f'CUDA Available: {torch.cuda.is_available()}')"

Dev tools

# Check for errors
uv run ruff check .

# Formats the codebase
uv run ruff format .

Requirements

(tested on)
1. python == 3.13
2. pytorch == 2.1.1
3. torchvision == 0.16.1

Notes

# 1. I just have notebooks folder to verify all the classes that I create of the model, dataset, evaluation metrics.

Implementation details

Step 1: Train Magic Point on Synthetic Dataset

Image of synthetic dataset created using cubes - shapes.py

alt text

Image of synthetic dataset created using checkerboards - shapes.py

alt text

Sample of Data Augmentations used in Synthetic Dataset

One thing that I think I will avoid is to set keypoints at intersections that exist in 2D because of overlapping shapes but really they are not stable points to track. Imagine as the camera moves, the intersection keeps changing in the 2D space in the case shown below:

alt text

Notes on problems with geomtric augmentations

Sometimes, geometric augmentations can create artificial corners when the regions outside the boundary enter the image frame after the transformation as shown below. Look at the perspective and affine sections where ellipse now has two more corners that are missed out in the ground truth keypoints. 

I want to have perfect ground truth keypoints and hence, I will add cropping after geometric augmentations to avoid such cases. This ensures diversity that comes from perspective distortions without post-processing issues for new keypoint search.

alt text

I for now just implemented cropping after geometric augmentations just to avoid the above issue. In future, I can think of more robust ways to handle this.

alt text

Final Setup for Synthetic Dataset Augmentations

alt text

Training Magic Point

uv run train_magicpoint.py
1. 10e-4 learning rate with 100:1 weighted cross entropy loss did not converge well. Loss was around 2 after X epochs.
2. 10e-5 learning rate with 10:1 weighted cross entropy loss converged well. Loss was around 0.7 after Y epochs.
3. 10e-6 learning rate with 1:1 weighted cross entropy loss converged well. Loss was around 0.1 after Z epochs.

alt text

Final Results on Magic Point trained on Synthetic Dataset

alt text

Direct Results of Magic Point on Real Images without any Fine-tuning - Even Without Homographic Adaptation.

alt text

Training SuperPoint with Homographic Adaptation

alt text

Creating Pseudo Labels after Homographic Adaptation for coco5K Val Set

Download coco5K val set from:

# 1. Create the directories
mkdir -p data/coco

# 2. Download (using -c to allow resuming if connection drops)
wget -c http://images.cocodataset.org/zips/val2017.zip -P data/coco/

# 3. Extract and Cleanup
# This will extract into data/coco/val2017/
unzip data/coco/val2017.zip -d data/coco/
rm data/coco/val2017.zip

alt text

Model Architecture

alt text

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages