Pytorch Implementation of rpautrat/SuperPoint

Overview

SuperPoint-Pytorch (A Pure Pytorch Implementation)

SuperPoint: Self-Supervised Interest Point Detection and Description

Thanks

This work is based on:

New update (20211016)

  • Train your MagicPoint and SuperPoint

New update (20210904)

Usage

  • 1 Prepare your data. Make directories data and export. The data directory should look like,
    data
    |-- coco
    |  |-- train2017
    |  |     |-- a.jpg
    |  |     |-- ...
    |  `-- test2017
    |        |-- b.jpg
    |        |-- ...
    |-- hpatches
    |   |-- i_ajuntament
    |   |   |--1.ppm
    |   |   |--...
    |   |   |--H_1_2
    |   |-- ...
    
    You can create soft links if you already have coco, hpatches data sets, the command is,
    cd data
    ln -s dir_to_coco ./coco
    
  • 2 The training steps are much similar to rpautrat/Superpoint
    • 2.1 Train MagicPoint: python train.py ./config/magic_point_train.yaml
    • 2.2 Export coco labels: python export detections.py
    • 2.3 Train MagicPoint on coco labels data set (export by step 2.2)
      python train.py ./config/superpoint_train.py
    • 2.4 Train SuperPoint.py: python train.py ./config/superpoint_train.py
    • others. Validate detection repeatability:
    python export detections_repeatability.py   
    python compute_repeatability.py
    
    (NOTE: You have to edit *.yaml files to run corresponding tasks, especially for the following items
    model
        name: superpoint # magicpoint
     ...
    data:
        name: coco #synthetic
        image_train_path: ['./data/mp_coco_v2/images/train2017',] #several data sets can be list here
        label_train_path: ['./data/mp_coco_v2/labels/train2017/',]
        image_test_path: './data/mp_coco_v2/images/test2017/'
        label_test_path: './data/mp_coco_v2/labels/test2017/'
    
Comments
  • Training speed and results

    Training speed and results

    Sorry to bother you, I have two question about this project. for training work, I use multi gpus, the speed about 1.79it/s in first two epoch, it takes one day. After that, the speed is so fast, I don't know why this happened. Also the result, the detections repeatability is more better than rpautrat/Superpoint's, but the descriptors: hpatches-i is 0.90. hpatches-v is 0.55. Compare with rpautrat/Superpoint's, the result is not good.

    opened by litingsjj 29
  • 训练完成后使用时爆显存的问题

    训练完成后使用时爆显存的问题

    作者您好!我在训练完成后使用Superpoint推断时发现即使设置了with torch.no_grad():,当我连续推断两张图片时显存溢出,并且速度很慢,一张480p的图片放在gpu上需要1s `device = 'cuda:0' if torch.cuda.is_available() else 'cpu' # device='cpu' net = SuperPointBNNet(config['model'], device=device, using_bn=config['model']['using_bn']) net.load_state_dict(torch.load(config['model']['pretrained_model'],map_location=device)) net.to(device).eval()

    example = cv2.imread("/home/xiefei/COCO_test2014_000000000001.jpg",0)
    img_tensor = torch.as_tensor(example.copy(), dtype=torch.float, device=device)
    img_tensor=img_tensor/255.
    img_tensor=img_tensor.unsqueeze(0)
    img_tensor=img_tensor.unsqueeze(0)
    
    with torch.no_grad():
        t1=time.time()
        output=net(img_tensor)
        t2=time.time()
        print(t2-t1)`
    
    opened by FeiXie8 5
  • README.md 中的 Usage 中是否有几个错误

    README.md 中的 Usage 中是否有几个错误

    首先感谢您的工作 我是一个深度学习新手 我在阅读 README.md 时,发现可能存在一些笔误,虽然不影响代码的运行,但是给我带来了一些困扰,比如 Usage 2.0 中表述的 in train.py, line 61,实际上由于代码改动,好像不在那一行了。 2.4 和 2.6 中的 python train.py ./config/magic_point_coco_train.py #with correct data dirs 和 python train.py ./config/superpoint_train.py #with correct data dirs 表述的 ./config/.py 是否应为 ./config/.yaml 。

    opened by ZhihangCui 3
  • RuntimeError: dets should have the same type as scores

    RuntimeError: dets should have the same type as scores

    Envs is installed as required.

    0it [00:00, ?it/s]D:\Users\sichu\anaconda3\envs\point-torch\lib\site-packages\kornia\utils\helpers.py:96: UserWarning: torch.solve is deprecated in favor of torch.linalg.solveand will be removed in a future PyTorch release. torch.linalg.solve has its arguments reversed and does not return the LU factorization. To get the LU factorization see torch.lu, which can be used with torch.lu_solve or torch.lu_unpack. X = torch.solve(B, A).solution should be replaced with X = torch.linalg.solve(A, B) (Triggered internally at ..\aten\src\ATen\native\BatchLinearAlgebra.cpp:760.) out1, out2 = torch.solve(input.to(dtype), A.to(dtype)) D:\Users\sichu\anaconda3\envs\point-torch\lib\site-packages\torch\nn\functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at ..\c10/core/TensorImpl.h:1156.) return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)

    Traceback (most recent call last): File "train.py", line 139, in train_eval(model, data_loaders, config) File "train.py", line 30, in train_eval raw_outputs = model(data['raw']) File "D:\Users\sichu\anaconda3\envs\point-torch\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "D:\experments\SuperPoint-Pytorch-master\SuperPoint-Pytorch-master\model\magic_point.py", line 42, in forward keep_top_k=self.topk).squeeze(dim=0) for p in prob] File "D:\experments\SuperPoint-Pytorch-master\SuperPoint-Pytorch-master\model\magic_point.py", line 42, in keep_top_k=self.topk).squeeze(dim=0) for p in prob] File "D:\experments\SuperPoint-Pytorch-master\SuperPoint-Pytorch-master\solver\nms.py", line 45, in box_nms indices = torchvision.ops.nms(boxes=boxes, scores=scores, iou_threshold=iou) File "D:\Users\sichu\anaconda3\envs\point-torch\lib\site-packages\torchvision\ops\boxes.py", line 35, in nms return torch.ops.torchvision.nms(boxes, scores, iou_threshold) RuntimeError: dets should have the same type as scores

    opened by samadhiiiii 3
  • RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 1, 3, 3], but got 3-dimensional input of size [16, 120, 160] instead

    RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 1, 3, 3], but got 3-dimensional input of size [16, 120, 160] instead

    RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 1, 3, 3], but got 3-dimensional input of size [16, 120, 160] instead

    my envs: cuda11.0 cudnn8.0.5 torch 1.7.1+cu110

    opened by yangninghua 2
  • Inference or demo codes using the pretrained models?

    Inference or demo codes using the pretrained models?

    Hi, fantastic work done! Applause for you!!

    May I know if there is any instruction or codes for a quick demo using pre-trained models? Thank you in advance!

    Also, may I know: between the weight released by magicleap and the weight released by rpautrat's superpoint, which one has better performance?

    opened by ZhangGongjie 1
  • train superpoint时的超参数设置

    train superpoint时的超参数设置

    作者您好,我注意到您在训练superpoint时的descriptor loss部分的lambda_d设置为0.05。这个lambda_d不是添加在正样本上的权重吗?(正样本数量较少,理应设置大点的权重)Superpoint的作者在论文中陈述的设置为250,您为什么使用0.05呢?是您在实际训练中找到的更合适的新参数吗? https://github.com/shaofengzeng/SuperPoint-Pytorch/blob/master/config/superpoint_train.yaml

    我在训练时给正样本设置大的权重也没有获得好的效果,看到您这么设置,能不能问下这么设置的原因呢?

    opened by fish258 1
  • Cuda: out of memory

    Cuda: out of memory

    作者您好,近期在遵循您给出的训练步骤进行复现时,发现如果将输入图片尺寸修改为[480, 640],则代码将无法正常工作,并提示显存不足,我目前所采用的设备是2080Ti显卡,8G显存,因为我个人觉得依照这个网络模型,[480,640]的图片尺寸不应该出现超出8G显存的问题,针对超出显存的报错,我不知道问题出在了哪里,我在训练的过程中即使将batch_size修改为1仍然会提示超出显存,所以想请教一下您,为什么网络面向[480,640]的图片尺寸时即使batch_size为1还会出现显存不够的问题呢?期待您的回复

    opened by hjr553199215 1
  • relationship between superpoint_v1.pth and superpointbn.pth

    relationship between superpoint_v1.pth and superpointbn.pth

    I guess superpoint_v1 is the pytorch version model file converted by the TF version. Is the superpointbn.pth have same weights as the former one except the modified parts (I see that in the bn version, you made some modifications on the architecture)?

    opened by fish258 1
  • Crop in augmentation_legacy.py

    Crop in augmentation_legacy.py

    请问在dataset/utils/augmentation_legacy.py文件的elastic_transform函数中为什么会按照如下的方式定义min_row,max_row,min_col,max_col min_row = int(math.ceil(np.max(dy))) + padding
    max_row = int(math.floor(np.min(dy))) + shape[0] - padding
    min_col = int(math.ceil(np.max(dx))) + padding max_col = int(math.floor(np.min(dx))) + shape[1] - padding

    opened by hjr553199215 1
  • coco images size when superpoint trainning

    coco images size when superpoint trainning

    Hi, thanks for your great job, if I trained magic point with rpautrat's project to get coco gt points, then use your version to train superpoint, will transforming the coco image to 240* 320 by function ratio_preserving_resize have a big impact on the results?

    opened by sunwen-nreal 0
  • multi GPU train

    multi GPU train

    How should I modify the code to conduct multi GPU training? At the end of train.py file the following code is added before train_eval(model, data_loaders, config) function.

    if torch.cuda.device_count() > 1: 
        model = torch.nn.DataParallel(model, device_ids=list(range(torch.cuda.device_count()))
    model.to(device)
    

    After that, When I train the code, I get the following messages.

    Traceback (most recent call last):
      File "train.py", line 212, in <module>
        train_eval(model, data_loaders, config)
      File "train.py", line 84, in train_eval
        prob_warp, desc_warp, device)
      File "/root/Source/gtr/SuperPoint_pytorch/temp/SuperPoint-Pytorch-master/solver/loss.py", line 16, in loss_func
        device=device)
      File "/root/Source/gtr/SuperPoint_pytorch/temp/SuperPoint-Pytorch-master/solver/loss.py", line 65, in detector_loss
        ce_loss = F.cross_entropy(logits, labels, reduction='none',)
      File "/root/PersonalData/miniconda/envs/superpoint/lib/python3.7/site-packages/torch/nn/functional.py", line 3026, in cross_entropy
        return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
    ValueError: Expected input batch_size (16) to match target batch_size (64).
    

    It seems to be the problem of data set allocation under multi GPU training. But I don't know how to modify it.

    opened by RaneWouters 2
  • About  magic_point_coco_train.yaml

    About magic_point_coco_train.yaml

    Hi, thanks for your great job. I want to train magicpoint on kitti , so is it needed to use magic_point_coco_train.yaml ? I noticed there is a path of labels. but how to ensure its correctness so as to train magicpoint ? because if the label result generated in the previous step is average, what is the significance of this step of train magicpoint ?

    opened by foxkw 1
Owner
null
ALBERT-pytorch-implementation - ALBERT pytorch implementation

ALBERT-pytorch-implementation developing... 모델의 개념이해를 돕기 위한 구현물로 현재 변수명을 상세히 적었고

BG Kim 3 Oct 6, 2022
An essential implementation of BYOL in PyTorch + PyTorch Lightning

Essential BYOL A simple and complete implementation of Bootstrap your own latent: A new approach to self-supervised Learning in PyTorch + PyTorch Ligh

Enrico Fini 48 Sep 27, 2022
RealFormer-Pytorch Implementation of RealFormer using pytorch

RealFormer-Pytorch Implementation of RealFormer using pytorch. Includes comparison with classical Transformer on image classification task (ViT) wrt C

Simo Ryu 90 Dec 8, 2022
A PyTorch implementation of the paper Mixup: Beyond Empirical Risk Minimization in PyTorch

Mixup: Beyond Empirical Risk Minimization in PyTorch This is an unofficial PyTorch implementation of mixup: Beyond Empirical Risk Minimization. The co

Harry Yang 121 Dec 17, 2022
A pytorch implementation of Pytorch-Sketch-RNN

Pytorch-Sketch-RNN A pytorch implementation of https://arxiv.org/abs/1704.03477 In order to draw other things than cats, you will find more drawing da

Alexis David Jacq 172 Dec 12, 2022
PyTorch implementation of Advantage async actor-critic Algorithms (A3C) in PyTorch

Advantage async actor-critic Algorithms (A3C) in PyTorch @inproceedings{mnih2016asynchronous, title={Asynchronous methods for deep reinforcement lea

LEI TAI 111 Dec 8, 2022
Pytorch-diffusion - A basic PyTorch implementation of 'Denoising Diffusion Probabilistic Models'

PyTorch implementation of 'Denoising Diffusion Probabilistic Models' This reposi

Arthur Juliani 76 Jan 7, 2023
Fang Zhonghao 13 Nov 19, 2022
RETRO-pytorch - Implementation of RETRO, Deepmind's Retrieval based Attention net, in Pytorch

RETRO - Pytorch (wip) Implementation of RETRO, Deepmind's Retrieval based Attent

Phil Wang 556 Jan 4, 2023
HashNeRF-pytorch - Pure PyTorch Implementation of NVIDIA paper on Instant Training of Neural Graphics primitives

HashNeRF-pytorch Instant-NGP recently introduced a Multi-resolution Hash Encodin

Yash Sanjay Bhalgat 616 Jan 6, 2023
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.

NN Template Generic template to bootstrap your PyTorch project. Click on Use this Template and avoid writing boilerplate code for: PyTorch Lightning,

Luca Moschella 520 Dec 30, 2022
A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch

This repository holds NVIDIA-maintained utilities to streamline mixed precision and distributed training in Pytorch. Some of the code here will be included in upstream Pytorch eventually. The intention of Apex is to make up-to-date utilities available to users as quickly as possible.

NVIDIA Corporation 6.9k Jan 3, 2023
Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

30 Days Of Machine Learning Using Pytorch Objective of the repository is to learn and build machine learning models using Pytorch. List of Algorithms

Mayur 119 Nov 24, 2022
Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pytorch Lightning 1.4k Jan 1, 2023
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 360 Dec 10, 2022
The Incredible PyTorch: a curated list of tutorials, papers, projects, communities and more relating to PyTorch.

This is a curated list of tutorials, projects, libraries, videos, papers, books and anything related to the incredible PyTorch. Feel free to make a pu

Ritchie Ng 9.2k Jan 2, 2023
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 359 Jan 5, 2023
A bunch of random PyTorch models using PyTorch's C++ frontend

PyTorch Deep Learning Models using the C++ frontend Gettting started Clone the repo 1. https://github.com/mrdvince/pytorchcpp 2. cd fashionmnist or

Vince 0 Jul 13, 2021
PyTorch Autoencoders - Implementing a Variational Autoencoder (VAE) Series in Pytorch.

PyTorch Autoencoders Implementing a Variational Autoencoder (VAE) Series in Pytorch. Inspired by this repository Model List check model paper conferen

Subin An 8 Nov 21, 2022