Giter Site home page Giter Site logo

Comments (5)

nobobobo avatar nobobobo commented on May 31, 2024

uploading two images I used for testing

01
02

from glue-factory.

sarlinpe avatar sarlinpe commented on May 31, 2024

Can you share the code that yields the first results? Here's what I get with your images and SuperPoint-Open:
sp-open_points
sp-open_matches

import torch
from gluefactory.utils.image import ImagePreprocessor
from gluefactory.visualization.viz2d import plot_images, plot_keypoints, plot_matches
from gluefactory.models.extractors.superpoint_open import SuperPoint
from gluefactory.models.matchers.nearest_neighbor_matcher import NearestNeighborMatcher

improc = ImagePreprocessor({'resize': 1024})
im0 = improc.load_image('test_data/receipt1.jpg')['image']
im1 = improc.load_image('test_data/receipt2.jpg')['image']

sp = SuperPoint({'nms_radius': 4}).cuda().eval()
with torch.no_grad():
    pred0 = sp({'image': im0.cuda()[None]})
    pred1 = sp({'image': im1.cuda()[None]})

pts0, pts1 = [p['keypoints'].squeeze(0).cpu() for p in (pred0, pred1)]
plot_images([im.permute(1,2,0) for im in (im0, im1)],
            titles=[f'{len(p)} keypoints' for p in (pts0, pts1)])
plot_keypoints([pts0, pts1])


matcher = NearestNeighborMatcher({"distance_thresh": 0.5})
matches = matcher({'descriptors0': pred0['descriptors'], 'descriptors1': pred1['descriptors']})['matches0'].squeeze(0)

plot_images([im.permute(1,2,0) for im in (im0, im1)])
plot_matches(pts0[matches.cpu()!=-1], pts1[matches[matches!=-1].cpu()], a=0.5, lw=1)

from glue-factory.

nobobobo avatar nobobobo commented on May 31, 2024

Thanks for trying!

I just ran your code snippet on my end, it seems SuperPoint-Open generates different results with two versions of torch: 2.0.1 and 2.1.0. The difference might be because of some changes implemented in the new PyTorch, which was just relased couple days ago. So for now, I will use torch 2.0.1 for workaround.

Screenshot 2023-10-18 at 12 44 41 PM
Screenshot 2023-10-18 at 12 41 22 PM

import torch 
print(torch.__version__)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

from gluefactory.utils.image import ImagePreprocessor
from gluefactory.models.extractors.superpoint_open import SuperPoint
from gluefactory.visualization.viz2d import plot_images, plot_keypoints, plot_matches

improc = ImagePreprocessor({'resize': 1024})
im0 = improc.load_image('../../test_images/01.jpeg')['image']
im1 = improc.load_image('../../test_images/02.jpeg')['image']

sp = SuperPoint({'nms_radius': 4}).cuda().eval()
with torch.no_grad():
    pred0 = sp({'image': im0.cuda()[None]})
    pred1 = sp({'image': im1.cuda()[None]})

pts0, pts1 = [p['keypoints'].squeeze(0).cpu() for p in (pred0, pred1)]
plot_images([im.permute(1,2,0) for im in (im0, im1)],
            titles=[f'{len(p)} keypoints' for p in (pts0, pts1)])
plot_keypoints([pts0, pts1])

from glue-factory.

sarlinpe avatar sarlinpe commented on May 31, 2024

I obtain the exact same results with torch 2.1.0+cu121, 2.0.1+cu117, and 2.0.0+cu117.

from glue-factory.

nobobobo avatar nobobobo commented on May 31, 2024

Okay, thank you for checking. I will test again with a clean environment here as well. Close this issue for the time being.

from glue-factory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.