Giter Site home page Giter Site logo

kamata1729 / qatm_pytorch Goto Github PK

View Code? Open in Web Editor NEW
166.0 9.0 49.0 4.16 MB

Pytorch Implementation of QATM:Quality-Aware Template Matching For Deep Learning

Home Page: https://arxiv.org/abs/1903.07254

License: MIT License

Jupyter Notebook 51.97% Python 48.03%
pytorch cnn template-matching deep-learning python

qatm_pytorch's Introduction

Pytorch Non-Official Implementation of QATM:Quality-Aware Template Matching For Deep Learning

arxiv: https://arxiv.org/abs/1903.07254
original code (tensorflow+keras): https://github.com/cplusx/QATM
Qiita(Japanese): https://qiita.com/kamata1729/items/11fd55992c740526f6fc

Dependencies

  • torch(1.0.0)
  • torchvision(0.2.1)
  • cv2
  • seaborn
  • sklearn
  • pathlib

Usage

See qatm_pytorch.ipynb

or

python qatm.py -s sample/sample1.jpg -t template --cuda
  • Add --cuda option to use GPU
  • Add -s/--sample_image to specify sample image
    only single sample image can be specified in this present implementation
  • Add -t/--template_images_dir to specify template image dir

[notice] If neither -s nor -t is specified, the demo program will be executed, which is the same as:

python qatm.py -s sample/sample1.jpg -t template
  • --thresh_csv and --alpha option can also be added

Result of Demo

template1_1.png to template1_4.png are contained in sample1.jpg, however, template1_dummy.png is a dummy and not contained

template1_1.png template1_2.png template1_3.png template1_4.png template1_dummy.png
image.png image.png

image.png

qatm_pytorch's People

Contributors

arka161 avatar feelgom avatar kamata1729 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qatm_pytorch's Issues

score is nan

ソースコードを共有していただきありがとうございます。
お伺いしたいことがあります。
デモのテンプレートマッチングはおこなうことができました。
そこで自分の画像とテンプレートでマッチングを行ったところ以下のようになりました。
Screenshot from 2019-08-06 16-27-51
Screenshot from 2019-08-06 16-28-33

詳しく見るとrun_one_sample関数下の
val = model(template, image, image_name)でvalがnanと返ってきました。
どのような原因が考えられるでしょうか。
アドバイスいただけるとありがたいです。

追加情報として
テンプレートとマッチング画像の拡張子はdemoのときと同じですが、サイズはテンプレートしかおなじではありません。
また、テンプレートはマッチング画像から切り取ったものではなく、人間の目で見てもテンプレートがマッチング画像に含まれているか判断が困難な画像を使っています。

Threshold function always got one match?

I think below function may be always got at least one matching.

def nms(score, w_ini, h_ini, thresh=0.7):
    dots = np.array(np.where(score > thresh*score.max()))

may be need change "score.max()" to a constant (0.1~0.2).

Poor performance on BBS dataset

I have tested this implementation on BBS dataset, but get poor performance, specifically, nearly zero accuracy. I wonder if you could test it and post the testing code. Thank you.

Slow and out of memory

As I tested, it's much slower than NCC, and always out of memory for big images (4000*4000), any suggestion?

TypeError: einsum() takes 2 positional arguments but 3 were given

when I run
python qatm.py -s sample/sample1.jpg -t template --cuda

Result
import qatm_pytorch.py...
define model...
calculate score...
Traceback (most recent call last):
File "qatm.py", line 46, in
scores, w_array, h_array, thresh_list = run_multi_sample(model, dataset)
File "mod.py", line 333, in run_multi_sample
File "mod.py", line 306, in run_one_sample
File "mod.py", line 150, in call
TypeError: einsum() takes 2 positional arguments but 3 were given

I would appreciate if you give me any advice~

About License

Dear @kamata1729 ,

I find this OSS useful and I want to use it in my software and include it in my software distribution.

In this case, can I comply with the MIT License for this?

The README states that the original code is QATM(https://github.com/cplusx/QATM) and the license can only be used by non-commercial or academic.
Is QATM_pytorch only required to comply with MIT apart from QATM?

ResNet101 instead of VGG16?

Can we use a pretrained resnet101 instead of vgg? If yes, which two layers' outputs do we use with 'register_forward_hook'?

Runs out of memory

Hi,

My template image is
template
And my sample image is
design

My system is running out of memory during the calculate scores phase.

Do you have any suggestions for this?

Thanks,
Shamik

TypeError: pic should be PIL Image or ndarray. Got <class 'NoneType'>

Dear authors,
Really appreciate your wonderful contributions, but unfortunately, I did encounter some problem while I am trying to use the project. When I tried to match my own template with my own sample picture, I get this error: "TypeError: pic should be PIL Image or ndarray. Got <class 'NoneType'>". Are there any formatting problems that might cause this issue?
Thank you so much

no matching!!!

Hi,
Thank you for the code. But please test it and then post. There seems to be no matching whatsoever with any template and any image. I even tried matching template with the same image from where I made the template out....Still no matching.

How to use multiple images instead of just one sample image

How to use multiple images for the template matching?
I see that you have a function called run_multi_sample, but from thereafter, the plot doesn't seem to be the plot of each image that's processed for the templates - matching. Please clarify. I am trying to use this for multiple images not just one.

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.