Code Monkey home page Code Monkey logo

tfeat's Introduction

TFeat C++ Frontend/API

This repository is forked from TFeat.
Additionally C++ frontend / API example (for PyTorch) is placed here. If you want to use this, you should do the following.

How to use

  1. Export a model using export_model.ipynb.
    Now you have tfeat_model.pt. This is loaded by a cpp-example.

  2. Download and unzip libtorch. This is necessary if we use cpp-frontend of PyTroch.

    cd cpp_example && bash setup_libtorch.sh
  3. Compile tfeat_demo.cpp using CMakeLists.txt.

    mkdir build && cd build
    cmake .. && make
  4. Execute tfeat_demo in build!

    (e.g.) ./tfeat_demo ../../tfeat_model.pt ../../imgs/v_churchill/1.ppm ../../imgs/v_churchill/6.ppm

Result

This figure is the result of the above.

tfeat_cpp_example

Note

As you know, C++ API of PyTorch is "beta" stability.
Now this implementation works on my environment(Ubuntu18, Pytorch1.0), but in the future this may not work.
By the way, the result of C++ API is slightly different from the result of Python. I'm investigating this issue.


TFeat shallow convolutional patch descriptor

Code for the BMVC 2016 paper Learning local feature descriptors with triplets and shallow convolutional neural networks

Pre-trained models

We provide the following pre-trained models:

network name model link training dataset
tfeat-liberty tfeat-liberty.params liberty (UBC)
tfeat-yosemite tfeat-yosemite.params yosemite (UBC)
tfeat-notredame tfeat-notredame.params notredame (UBC)
tfeat-ubc coming soon... all UBC
tfeat-hpatches coming soon... HPatches (split A)
tfeat-all coming soon... All the above

Quick start guide

To run TFeat on a tensor of patches:

tfeat = tfeat_model.TNet()
net_name = 'tfeat-liberty'
models_path = 'pretrained-models'
net_name = 'tfeat-liberty'
tfeat.load_state_dict(torch.load(os.path.join(models_path,net_name+".params")))
tfeat.cuda()
tfeat.eval()

x = torch.rand(10,1,32,32).cuda()
descrs = tfeat(x)
print(descrs.size())

#torch.Size([10, 128])

Note that no normalisation is needed for the input patches, it is done internally inside the network.

Testing TFeat: Examples (WIP)

We provide an ipython notebook that shows how to load and use the pre-trained networks. We also provide the following examples:

  • extracting descriptors from image patches
  • matching two images using openCV
  • matching two images using vlfeat

For the testing example code, check tfeat-test notebook

Re-training TFeat

We provide an ipython notebook with examples on how to train TFeat. Training can either use the UBC datasets Liberty, Notredame, Yosemite, the HPatches dataset, and combinations of all the datasets.

For the training code, check tfeat-train notebook

tfeat's People

Contributors

cashiwamochi avatar ducha-aiki avatar edgarriba avatar vbalnt avatar

Watchers

 avatar

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.