Spaces:
Sleeping
Sleeping
Realcat
commited on
Commit
β’
2d554b0
1
Parent(s):
57c1094
update: rename common -> ui
Browse files- .github/workflows/format.yml +3 -3
- .gitignore +1 -0
- README.md +1 -1
- app.py +2 -2
- format.sh +3 -3
- pyproject.toml +2 -2
- test_app_cli.py +3 -3
- {common β ui}/__init__.py +0 -0
- {common β ui}/api.py +1 -1
- {common β ui}/app_class.py +39 -29
- {common β ui}/config.yaml +0 -0
- {common β ui}/sfm.py +0 -0
- {common β ui}/utils.py +0 -0
- {common β ui}/viz.py +0 -0
.github/workflows/format.yml
CHANGED
@@ -19,6 +19,6 @@ jobs:
|
|
19 |
cache: 'pip'
|
20 |
- run: python -m pip install --upgrade pip
|
21 |
- run: python -m pip install .[dev]
|
22 |
-
- run: python -m flake8
|
23 |
-
- run: python -m isort
|
24 |
-
- run: python -m black
|
|
|
19 |
cache: 'pip'
|
20 |
- run: python -m pip install --upgrade pip
|
21 |
- run: python -m pip install .[dev]
|
22 |
+
- run: python -m flake8 ui/*.py hloc/*.py hloc/matchers/*.py hloc/extractors/*.py
|
23 |
+
- run: python -m isort ui/*.py hloc/*.py hloc/matchers/*.py hloc/extractors/*.py --check-only --diff
|
24 |
+
- run: python -m black ui/*.py hloc/*.py hloc/matchers/*.py hloc/extractors/*.py --check --diff
|
.gitignore
CHANGED
@@ -24,3 +24,4 @@ experiments*
|
|
24 |
gen_example.py
|
25 |
datasets/lines/terrace0.JPG
|
26 |
datasets/lines/terrace1.JPG
|
|
|
|
24 |
gen_example.py
|
25 |
datasets/lines/terrace0.JPG
|
26 |
datasets/lines/terrace1.JPG
|
27 |
+
datasets/South-Building*
|
README.md
CHANGED
@@ -112,7 +112,7 @@ then open http://localhost:7860 in your browser.
|
|
112 |
|
113 |
### Add your own feature / matcher
|
114 |
|
115 |
-
I provide an example to add local feature in [hloc/extractors/example.py](hloc/extractors/example.py). Then add feature settings in `confs` in file [hloc/extract_features.py](hloc/extract_features.py). Last step is adding some settings to `model_zoo` in file [
|
116 |
|
117 |
## Contributions welcome!
|
118 |
|
|
|
112 |
|
113 |
### Add your own feature / matcher
|
114 |
|
115 |
+
I provide an example to add local feature in [hloc/extractors/example.py](hloc/extractors/example.py). Then add feature settings in `confs` in file [hloc/extract_features.py](hloc/extract_features.py). Last step is adding some settings to `model_zoo` in file [ui/config.yaml](ui/config.yaml).
|
116 |
|
117 |
## Contributions welcome!
|
118 |
|
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import argparse
|
2 |
from pathlib import Path
|
3 |
-
from
|
4 |
|
5 |
if __name__ == "__main__":
|
6 |
parser = argparse.ArgumentParser()
|
@@ -19,7 +19,7 @@ if __name__ == "__main__":
|
|
19 |
parser.add_argument(
|
20 |
"--config",
|
21 |
type=str,
|
22 |
-
default=Path(__file__).parent / "
|
23 |
help="config file",
|
24 |
)
|
25 |
args = parser.parse_args()
|
|
|
1 |
import argparse
|
2 |
from pathlib import Path
|
3 |
+
from ui.app_class import ImageMatchingApp
|
4 |
|
5 |
if __name__ == "__main__":
|
6 |
parser = argparse.ArgumentParser()
|
|
|
19 |
parser.add_argument(
|
20 |
"--config",
|
21 |
type=str,
|
22 |
+
default=Path(__file__).parent / "ui/config.yaml",
|
23 |
help="config file",
|
24 |
)
|
25 |
args = parser.parse_args()
|
format.sh
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
python -m flake8
|
2 |
-
python -m isort
|
3 |
-
python -m black
|
|
|
1 |
+
python -m flake8 ui/*.py hloc/*.py hloc/matchers/*.py hloc/extractors/*.py
|
2 |
+
python -m isort ui/*.py hloc/*.py hloc/matchers/*.py hloc/extractors/*.py
|
3 |
+
python -m black ui/*.py hloc/*.py hloc/matchers/*.py hloc/extractors/*.py
|
pyproject.toml
CHANGED
@@ -20,10 +20,10 @@ dynamic = ["dependencies"]
|
|
20 |
dev = ["black", "flake8", "isort"]
|
21 |
|
22 |
[tool.setuptools.packages.find]
|
23 |
-
include = ["hloc*", "
|
24 |
|
25 |
[tool.setuptools.package-data]
|
26 |
-
|
27 |
|
28 |
[tool.setuptools.dynamic]
|
29 |
dependencies = {file = ["requirements.txt"]}
|
|
|
20 |
dev = ["black", "flake8", "isort"]
|
21 |
|
22 |
[tool.setuptools.packages.find]
|
23 |
+
include = ["hloc*", "ui",]
|
24 |
|
25 |
[tool.setuptools.package-data]
|
26 |
+
ui = ["*.yaml"]
|
27 |
|
28 |
[tool.setuptools.dynamic]
|
29 |
dependencies = {file = ["requirements.txt"]}
|
test_app_cli.py
CHANGED
@@ -3,13 +3,13 @@ import warnings
|
|
3 |
import numpy as np
|
4 |
from pathlib import Path
|
5 |
from hloc import logger
|
6 |
-
from
|
7 |
get_matcher_zoo,
|
8 |
load_config,
|
9 |
DEVICE,
|
10 |
ROOT,
|
11 |
)
|
12 |
-
from
|
13 |
|
14 |
|
15 |
def test_all(config: dict = None):
|
@@ -109,6 +109,6 @@ def test_one():
|
|
109 |
|
110 |
|
111 |
if __name__ == "__main__":
|
112 |
-
config = load_config(ROOT / "
|
113 |
test_one()
|
114 |
test_all(config)
|
|
|
3 |
import numpy as np
|
4 |
from pathlib import Path
|
5 |
from hloc import logger
|
6 |
+
from ui.utils import (
|
7 |
get_matcher_zoo,
|
8 |
load_config,
|
9 |
DEVICE,
|
10 |
ROOT,
|
11 |
)
|
12 |
+
from ui.api import ImageMatchingAPI
|
13 |
|
14 |
|
15 |
def test_all(config: dict = None):
|
|
|
109 |
|
110 |
|
111 |
if __name__ == "__main__":
|
112 |
+
config = load_config(ROOT / "ui/config.yaml")
|
113 |
test_one()
|
114 |
test_all(config)
|
{common β ui}/__init__.py
RENAMED
File without changes
|
{common β ui}/api.py
RENAMED
@@ -289,5 +289,5 @@ class ImageMatchingAPI(torch.nn.Module):
|
|
289 |
|
290 |
|
291 |
if __name__ == "__main__":
|
292 |
-
config = load_config(ROOT / "
|
293 |
api = ImageMatchingAPI(config)
|
|
|
289 |
|
290 |
|
291 |
if __name__ == "__main__":
|
292 |
+
config = load_config(ROOT / "ui/config.yaml")
|
293 |
api = ImageMatchingAPI(config)
|
{common β ui}/app_class.py
RENAMED
@@ -6,8 +6,8 @@ import numpy as np
|
|
6 |
from easydict import EasyDict as edict
|
7 |
from omegaconf import OmegaConf
|
8 |
|
9 |
-
from
|
10 |
-
from
|
11 |
GRADIO_VERSION,
|
12 |
gen_examples,
|
13 |
generate_warp_images,
|
@@ -388,7 +388,7 @@ class ImageMatchingApp:
|
|
388 |
"outputs": "experiments/sfm",
|
389 |
}
|
390 |
)
|
391 |
-
|
392 |
|
393 |
def run(self):
|
394 |
self.app.queue().launch(
|
@@ -552,12 +552,17 @@ class AppBaseUI:
|
|
552 |
def __init__(self, cfg: Dict[str, Any] = {}):
|
553 |
self.cfg = OmegaConf.create(cfg)
|
554 |
self.inputs = edict({})
|
|
|
|
|
555 |
|
556 |
def _init_ui(self):
|
557 |
NotImplemented
|
558 |
|
559 |
def call(self, **kwargs):
|
560 |
-
|
|
|
|
|
|
|
561 |
|
562 |
|
563 |
class AppSfmUI(AppBaseUI):
|
@@ -566,6 +571,7 @@ class AppSfmUI(AppBaseUI):
|
|
566 |
assert "matcher_zoo" in self.cfg
|
567 |
self.matcher_zoo = self.cfg["matcher_zoo"]
|
568 |
self.sfm_engine = SfmEngine(cfg)
|
|
|
569 |
|
570 |
def init_retrieval_dropdown(self):
|
571 |
algos = []
|
@@ -756,36 +762,40 @@ class AppSfmUI(AppBaseUI):
|
|
756 |
gr.Textbox(
|
757 |
label="Retriangluation Details",
|
758 |
)
|
759 |
-
button_sfm = gr.Button("Run SFM", variant="primary")
|
760 |
-
model_3d = gr.Model3D(
|
761 |
interactive=True,
|
762 |
)
|
763 |
-
output_image = gr.Image(
|
764 |
label="SFM Visualize",
|
765 |
type="numpy",
|
766 |
image_mode="RGB",
|
767 |
interactive=False,
|
768 |
)
|
769 |
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
|
|
|
|
|
|
|
|
|
6 |
from easydict import EasyDict as edict
|
7 |
from omegaconf import OmegaConf
|
8 |
|
9 |
+
from ui.sfm import SfmEngine
|
10 |
+
from ui.utils import (
|
11 |
GRADIO_VERSION,
|
12 |
gen_examples,
|
13 |
generate_warp_images,
|
|
|
388 |
"outputs": "experiments/sfm",
|
389 |
}
|
390 |
)
|
391 |
+
sfm_ui.call_empty()
|
392 |
|
393 |
def run(self):
|
394 |
self.app.queue().launch(
|
|
|
552 |
def __init__(self, cfg: Dict[str, Any] = {}):
|
553 |
self.cfg = OmegaConf.create(cfg)
|
554 |
self.inputs = edict({})
|
555 |
+
self.outputs = edict({})
|
556 |
+
self.ui = edict({})
|
557 |
|
558 |
def _init_ui(self):
|
559 |
NotImplemented
|
560 |
|
561 |
def call(self, **kwargs):
|
562 |
+
NotImplemented
|
563 |
+
|
564 |
+
def info(self):
|
565 |
+
gr.Info("SFM is under construction.")
|
566 |
|
567 |
|
568 |
class AppSfmUI(AppBaseUI):
|
|
|
571 |
assert "matcher_zoo" in self.cfg
|
572 |
self.matcher_zoo = self.cfg["matcher_zoo"]
|
573 |
self.sfm_engine = SfmEngine(cfg)
|
574 |
+
self._init_ui()
|
575 |
|
576 |
def init_retrieval_dropdown(self):
|
577 |
algos = []
|
|
|
762 |
gr.Textbox(
|
763 |
label="Retriangluation Details",
|
764 |
)
|
765 |
+
self.ui.button_sfm = gr.Button("Run SFM", variant="primary")
|
766 |
+
self.outputs.model_3d = gr.Model3D(
|
767 |
interactive=True,
|
768 |
)
|
769 |
+
self.outputs.output_image = gr.Image(
|
770 |
label="SFM Visualize",
|
771 |
type="numpy",
|
772 |
image_mode="RGB",
|
773 |
interactive=False,
|
774 |
)
|
775 |
|
776 |
+
def call_empty(self):
|
777 |
+
self.ui.button_sfm.click(fn=self.info, inputs=[], outputs=[])
|
778 |
+
|
779 |
+
def call(self):
|
780 |
+
self.ui.button_sfm.click(
|
781 |
+
fn=self.sfm_engine.call,
|
782 |
+
inputs=[
|
783 |
+
self.inputs.matcher_key,
|
784 |
+
self.inputs.input_images, # images
|
785 |
+
self.inputs.camera_model,
|
786 |
+
self.inputs.camera_params,
|
787 |
+
self.inputs.max_keypoints,
|
788 |
+
self.inputs.keypoint_threshold,
|
789 |
+
self.inputs.match_threshold,
|
790 |
+
self.inputs.ransac_threshold,
|
791 |
+
self.inputs.ransac_confidence,
|
792 |
+
self.inputs.ransac_max_iter,
|
793 |
+
self.inputs.scene_graph,
|
794 |
+
self.inputs.global_feature,
|
795 |
+
self.inputs.top_k,
|
796 |
+
self.inputs.mapper_refine_focal_length,
|
797 |
+
self.inputs.mapper_refine_principle_points,
|
798 |
+
self.inputs.mapper_refine_extra_params,
|
799 |
+
],
|
800 |
+
outputs=[self.outputs.model_3d, self.outputs.output_image],
|
801 |
+
)
|
{common β ui}/config.yaml
RENAMED
File without changes
|
{common β ui}/sfm.py
RENAMED
File without changes
|
{common β ui}/utils.py
RENAMED
File without changes
|
{common β ui}/viz.py
RENAMED
File without changes
|