Giter VIP home page Giter VIP logo

vincentqyw / image-matching-webui Goto Github PK

View Code? Open in Web Editor NEW
487.0 12.0 40.0 174.03 MB

๐Ÿค— image matching toolbox webui

Home Page: https://huggingface.co/spaces/Realcat/image-matching-webui

License: Apache License 2.0

Python 99.38% CSS 0.11% Shell 0.11% Batchfile 0.11% Dockerfile 0.29%
feature-matching image-matching loftr superglue superpoint keypoint-matching visual-localization gradio lightglue sift

image-matching-webui's Introduction

Contributors Forks Stargazers Issues


$\color{red}{\textnormal{Image\ Matching\ WebUI}}$
find matches between 2 images

Description

This simple tool efficiently matches image pairs using multiple famous image matching algorithms. The tool features a Graphical User Interface (GUI) designed using gradio. You can effortlessly select two images and a matching algorithm and obtain a precise matching result. Note: the images source can be either local images or webcam images.

Here is a demo of the tool:

imw.mp4

The tool currently supports various popular image matching algorithms, namely:

How to use

HuggingFace

Just try it on HF

or deploy it locally following the instructions below.

Requirements

git clone --recursive https://github.com/Vincentqyw/image-matching-webui.git
cd image-matching-webui
conda env create -f environment.yaml
conda activate imw

or using docker:

docker pull vincentqin/image-matching-webui:latest
docker run -it -p 7860:7860 vincentqin/image-matching-webui:latest python app.py --server_name "0.0.0.0" --server_port=7860

Run demo

python3 ./app.py

then open http://localhost:7860 in your browser.

Add your own feature / matcher

I provide an example to add local feature in hloc/extractors/example.py. Then add feature settings in confs in file hloc/extract_features.py. Last step is adding some settings to matcher_zoo in file common/utils.py.

Contributions welcome!

External contributions are very much welcome. Please follow the PEP8 style guidelines using a linter like flake8 (reformat using command python -m black .). This is a non-exhaustive list of features that might be valuable additions:

  • add webcam support
  • add line feature matching algorithms
  • example to add a new feature extractor / matcher
  • ransac to filter outliers
  • add rotation images options before matching
  • support export matches to colmap (#issue 6)
  • add config file to set default parameters
  • dynamically load models and reduce GPU overload

Adding local features / matchers as submodules is very easy. For example, to add the GlueStick:

git submodule add https://github.com/cvg/GlueStick.git third_party/GlueStick

If remote submodule repositories are updated, don't forget to pull submodules with git submodule update --remote, if you only want to update one submodule, use git submodule update --remote third_party/GlueStick.

Contributors

Resources

Acknowledgement

This code is built based on Hierarchical-Localization. We express our gratitude to the authors for their valuable source code.

image-matching-webui's People

Contributors

aelsaer avatar karolmajek avatar mattiasmar avatar vincentqyw 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  avatar  avatar  avatar

image-matching-webui's Issues

pydantic_core._pydantic_core.ValidationError: 1 validation error for PredictBody

I'm using Windows and WSL, but I keep getting this error and can't really get it to work.

How do I fix this error please?

image

Task exception was never retrieved
future: <Task finished name='j7l5nczw6pi_3' coro=<Queue.process_events() done, defined at /home/qf/miniconda3/envs/imw/lib/python3.10/site-packages/gradio/queueing.py:342> exception=1 validation error for PredictBody
event_id
  Field required [type=missing, input_value={'data': ['data:image/jpe...on_hash': 'j7l5nczw6pi'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing>
Traceback (most recent call last):
  File "/home/qf/miniconda3/envs/imw/lib/python3.10/site-packages/gradio/queueing.py", line 346, in process_events
    client_awake = await self.gather_event_data(event)
  File "/home/qf/miniconda3/envs/imw/lib/python3.10/site-packages/gradio/queueing.py", line 219, in gather_event_data
    data, client_awake = await self.get_message(event, timeout=receive_timeout)
  File "/home/qf/miniconda3/envs/imw/lib/python3.10/site-packages/gradio/queueing.py", line 448, in get_message
    return PredictBody(**data), True
  File "/home/qf/miniconda3/envs/imw/lib/python3.10/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for PredictBody
event_id
  Field required [type=missing, input_value={'data': ['data:image/jpe...on_hash': 'j7l5nczw6pi'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing

Clone bug(lanet repository is over its data quota.)

Downloading checkpoints/PointModel_v0.pth (34 MB)
Error downloading object: checkpoints/PointModel_v0.pth (17c1adf): Smudge error: Error downloading checkpoints/PointModel_v0.pth (17c1adfc8c22b044a9538019101bae0740a9d054c1b4fecd80b52d642272b9ff): batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.

Errors logged to 'C:\Users\Administrator\Project\ORS2SEM\data\ๅฎž้ชŒ4\image-match\image-matching-webui.git\modules\third_party\lanet\lfs\logs\20240315T102550.0545338.log'.
Use git lfs logs last to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: checkpoints/PointModel_v0.pth: smudge filter lfs failed
fatal: Unable to checkout '58ec4881f43fa082fbd18a61477224266bdc111c' in submodule path 'third_party/lanet'

Adding support for estimating stereo pair geometry

Congrats on the project. Recently I played with and I like it. What I found interesting is that it would be nice for someone to estimate a fundamental matrix or a homography between the two images thus I added the necessary functionalities leveraging OpenCV. If you find this useful please let me know.

image

Bug in wrapped image pair

I believe that there is an issue there :

rectified_image1 = cv2.warpPerspective(
img1, H, (img0.shape[1] + img1.shape[1], img0.shape[0])
)

It should be

rectified_image1 = cv2.warpPerspective(
                img1, H, (img0.shape[1], img0.shape[0])
            )

Otherwise the wrapped image has the wrong size.

install question

need to source? I met this question when run main.py
File "image-matching-webui-main/hloc/matchers/sold2.py", line 11, in
from sold2.model.line_matcher import LineMatcher

benchmark

hey great repo , just a question can you shed any light on which techniques gave the best results (lower FPs and better accuracies)

COTR and Quadtree

Hi, thanks for posting this great code
Please add COTR and Quadtree as well
Thank you very much

how can I solve this?

bug:
how can I solve this?

(imw) maomao@maomao415:~/Codes/image-matching-webui$ python ./app.py Traceback (most recent call last): File "/home/maomao/Codes/image-matching-webui/./app.py", line 2, in <module> import gradio as gr File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module> import gradio.components as components File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/components/__init__.py", line 1, in <module> from gradio.components.annotated_image import AnnotatedImage File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/components/annotated_image.py", line 12, in <module> from gradio import utils File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/utils.py", line 353, in <module> class AsyncRequest: File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/utils.py", line 372, in AsyncRequest client = httpx.AsyncClient() File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/httpx/_client.py", line 1395, in __init__ proxy_map = self._get_proxy_map(proxies, allow_env_proxies) File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/httpx/_client.py", line 216, in _get_proxy_map return { File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/httpx/_client.py", line 217, in <dictcomp> key: None if url is None else Proxy(url=url) File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/httpx/_config.py", line 336, in __init__ raise ValueError(f"Unknown scheme for proxy URL {url!r}") ValueError: Unknown scheme for proxy URL URL('socks://127.0.0.1:7891/')

Export matches to colmap or other

This is a great webui, but kinda useful.

Is there/will be in future option to export matching data to colmap (or other similar programs) and batch processing option for using this webui in photogrammetry?

Running an error on Windows (both Win10 and 11 are)

*** Aborted at 1707060306 (unix time) try "date -d @1707060306" if you are using GNU date ***
@ 0x7ffdc24f4090 log2f
@ 0x7ff7812c1f5c OPENSSL_Applink
@ 0x7ffdb903f73f __C_specific_handler
@ 0x7ffdc4b1441f __chkstk
@ 0x7ffdc4a8e466 RtlFindCharInUnicodeString
@ 0x7ffdc4b1340e KiUserExceptionDispatcher
@ 0x7ffd6e1f264e void __cdecl __ExceptionPtrRethrow(void const * __ptr64)
@ 0x7ffc2f2b38de public: void __cdecl c10::ivalue::Future::markCompleted(void) __ptr64
@ 0x7ffc2f531e19 struct _object * __ptr64 __cdecl THPGenerator_initDefaultGenerator(struct at::Generator)
@ 0x7ffc2a70dea5 (unknown)
@ 0x7ffc2ac66b29 PyInit_pycolmap
@ 0x7ffd9ade1080 (unknown)
@ 0x7ffd9ade2715 __NLG_Return2
@ 0x7ffdc4b13c66 RtlCaptureContext2
@ 0x7ffc2a7109b9 (unknown)
@ 0x7ffd5d49fd0d PyCFunction_GetFlags
@ 0x7ffd5d45acf8 _PyObject_MakeTpCall
@ 0x7ffd5d464141 PyComplex_AsCComplex
@ 0x7ffd5d4a43e4 _PyObject_GenericGetAttrWithDict
@ 0x7ffd5d4a3d18 PyObject_GetAttr
@ 0x7ffd5d4a3969 PyObject_GetAttrString
@ 0x7ffc2a74609e PyInit_pycolmap
@ 0x7ffc2a79dc6d PyInit_pycolmap
@ 0x7ffc2a77651d PyInit_pycolmap
@ 0x7ffc2a734170 (unknown)
@ 0x7ffc2a740a48 PyInit_pycolmap
@ 0x7ffc2a74054e PyInit_pycolmap
@ 0x7ffd5d5a0db9 PyImport_AppendInittab
@ 0x7ffd5d5a074c PyImport_Import
@ 0x7ffd5d49f919 PyCFunction_GetFlags
@ 0x7ffd5d56f8fc PyEval_GetFuncDesc
@ 0x7ffd5d56a720 _PyEval_EvalFrameDefault
May I ask if you know the reason? Thank you very much

LightGlue gives errors

Hello, and thanks for your great work!

I am having errors whenever trying to use any combination of LightGlue.
I.e.
File "/home/mikkel/image-matching-webui/hloc/matchers/../../third_party/LightGlue/lightglue/lightglue.py", line 349, in forward
kpts0
, kpts1_ = data0['keypoints'], data1['keypoints']
IndexError: too many indices for tensor of dimension 4

Hope you can help

conda env: ResolvePackageNotFound:

Hello,
I get a lot of ResolvePackageNotFound errors from the conda environment.
Could you please regenerate the environment.yaml so to make sure it is up to date?
Thanks!

CONDA_RESTORE_FREE_CHANNEL=1 conda env create --name imw --file environment.yaml
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound: 
  - pyrsistent==0.18.1=py310he2412df_1
  - jpeg==9e=h8ffe710_1
  - m2w64-libwinpthread-git==5.0.0.4634.697f757=2
  - sip==6.5.1=py310h8a704f9_2
  - pywin32==303=py310he2412df_0
  - protobuf==3.19.1=py310hd77b12b_0
  - libbrotlidec==1.0.9=h8ffe710_7
  - jupyter==1.0.0=py310haa95532_7
  - m2w64-gcc-libgfortran==5.3.0=6
  - libglib==2.70.2=h3be07f2_4
  - pyqt==5.15.4=py310h8a704f9_0
    ...

Bug while returning matching score

Hi,

I was using LoFTR but I was unable to obtain the confidence score. Instead it always returned [1 1 1 1 ...].

I believe there is an issue there, and maybe it is the same for sparse detectors too :
https://github.com/Vincentqyw/image-matching-webui/blob/f87ed7aad49842ab0c542c220356dbeb12d717d1/hloc/match_dense.py#L373C1-L376C67

Indeed, loftr prediction function does not return score under the key "mconf", but under the key "scores", hence I modified the piece of code by taking into account the "scores" key :

        if "mconf" in pred.keys():
            ret["mconf"] = pred["mconf"].cpu().numpy()
        elif "scores" in pred.keys() :
            ret["mconf"] = pred["scores"].cpu().numpy()
        else:
            ret["mconf"] = np.ones_like(kpts0.cpu().numpy()[:,0])

And now I can retrieve the confidence score.

"Scores" works for LoFTR but I dit not try other detectors.

error when gluestick

[2023/09/04 05:01:50 hloc.matchers.gluestick INFO] Loading GlueStick model...
Traceback (most recent call last):
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/gradio/utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "/home/maomao/Codes/image-matching-webui/common/utils.py", line 330, in run_matching
    matcher = get_model(match_conf)
  File "/home/maomao/Codes/image-matching-webui/common/utils.py", line 19, in get_model
    model = Model(match_conf["model"]).eval().to(device)
  File "/home/maomao/Codes/image-matching-webui/hloc/utils/base_model.py", line 17, in __init__
    self._init(conf)
  File "/home/maomao/Codes/image-matching-webui/hloc/matchers/gluestick.py", line 83, in _init
    self.net = TwoViewPipeline(gluestick_conf)
  File "/home/maomao/Codes/image-matching-webui/hloc/matchers/../../third_party/GlueStick/gluestick/models/base_model.py", line 80, in __init__
    self._init(conf)
  File "/home/maomao/Codes/image-matching-webui/hloc/matchers/../../third_party/GlueStick/gluestick/models/two_view_pipeline.py", line 106, in _init
    self.matcher = get_model(conf.matcher.name)(conf.matcher)
  File "/home/maomao/Codes/image-matching-webui/hloc/matchers/../../third_party/GlueStick/gluestick/models/base_model.py", line 80, in __init__
    self._init(conf)
  File "/home/maomao/Codes/image-matching-webui/hloc/matchers/../../third_party/GlueStick/gluestick/models/gluestick.py", line 90, in _init
    state_dict = torch.load(conf.weights, map_location='cpu')
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/torch/serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/maomao/anaconda3/envs/imw/lib/python3.10/site-packages/torch/serialization.py", line 920, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
EOFError: Ran out of input

*** Aborted at 1711654442 (unix time) try "date -d @1711654442" if you are using GNU date ***

python app.py
*** Aborted at 1711654442 (unix time) try "date -d @1711654442" if you are using GNU date ***
@ 0x7ff8e89a0ef5 _seh_filter_exe
@ 0x7ff75abe1cfc (unknown)
@ 0x7ff8ca31ecd0 __C_specific_handler
@ 0x7ff8eae323af __chkstk
@ 0x7ff8eade14b4 RtlRaiseException
@ 0x7ff8eae30ebe KiUserExceptionDispatcher
@ 0x7ff8bf3f25ee void __cdecl __ExceptionPtrRethrow(void const * __ptr64)
@ 0x7ff85414135f (unknown)
@ 0x7ff85414393c (unknown)
@ 0x7ff84f92dea5 (unknown)
@ 0x7ff84fe86b29 PyInit_pycolmap
@ 0x7ff8c1171080 (unknown)
@ 0x7ff8c11726a5 __NLG_Return2
@ 0x7ff8eae31716 RtlCaptureContext2
@ 0x7ff84f9309b9 (unknown)
@ 0x7ff85660c24a PyObject_IsTrue
@ 0x7ff8565d60db _PyObject_MakeTpCall
@ 0x7ff856740045 _Py_gitversion
@ 0x7ff8565d946c _PyObject_GenericGetAttrWithDict
@ 0x7ff8565d8967 PyObject_GetAttr
@ 0x7ff856618831 PyObject_GetAttrString
@ 0x7ff84f96609e PyInit_pycolmap
@ 0x7ff84f9bdc6d PyInit_pycolmap
@ 0x7ff84f99651d PyInit_pycolmap
@ 0x7ff84f954170 (unknown)
@ 0x7ff84f960a48 PyInit_pycolmap
@ 0x7ff84f96054e PyInit_pycolmap
@ 0x7ff856692304 _Py_fopen_obj
@ 0x7ff856692519 _Py_fopen_obj
@ 0x7ff85669246d _Py_fopen_obj
@ 0x7ff8565e09d7 _Py_HashPointer
@ 0x7ff8566193b4 PyVectorcall_Call

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.