Spaces:
Runtime error
Runtime error
update: ui
Browse files- common/app_class.py +209 -22
common/app_class.py
CHANGED
|
@@ -377,31 +377,15 @@ class ImageMatchingApp:
|
|
| 377 |
],
|
| 378 |
outputs=[output_wrapped, geometry_result],
|
| 379 |
)
|
| 380 |
-
with gr.Tab("
|
| 381 |
self.init_tab_sfm()
|
| 382 |
|
| 383 |
def init_tab_sfm(self):
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
gr.Textbox("Under construction", label="C", visible=True)
|
| 390 |
-
with gr.Row():
|
| 391 |
-
with gr.Accordion("Open for More", open=False):
|
| 392 |
-
gr.Textbox(
|
| 393 |
-
"Under construction", label="A1", visible=True
|
| 394 |
-
)
|
| 395 |
-
gr.Textbox(
|
| 396 |
-
"Under construction", label="B1", visible=True
|
| 397 |
-
)
|
| 398 |
-
gr.Textbox(
|
| 399 |
-
"Under construction", label="C1", visible=True
|
| 400 |
-
)
|
| 401 |
-
with gr.Column():
|
| 402 |
-
gr.Textbox("Under construction", label="D", visible=True)
|
| 403 |
-
gr.Textbox("Under construction", label="E", visible=True)
|
| 404 |
-
gr.Textbox("Under construction", label="F", visible=True)
|
| 405 |
|
| 406 |
def run(self):
|
| 407 |
self.app.queue().launch(
|
|
@@ -559,3 +543,206 @@ class ImageMatchingApp:
|
|
| 559 |
# height=1000,
|
| 560 |
)
|
| 561 |
return tab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ab_sfm()
|
| 382 |
|
| 383 |
def init_tab_sfm(self):
|
| 384 |
+
sfm_ui = AppSfmUI()
|
| 385 |
+
sfm_ui.set_local_features(["disk", "superpoint"])
|
| 386 |
+
sfm_ui.set_matchers(["disk+lightglue", "superpoint+lightglue"])
|
| 387 |
+
sfm_ui.set_global_features(["netvlad", "mixvpr"])
|
| 388 |
+
sfm_ui.call()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
def run(self):
|
| 391 |
self.app.queue().launch(
|
|
|
|
| 543 |
# height=1000,
|
| 544 |
)
|
| 545 |
return tab
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
class AppBaseUI:
|
| 549 |
+
def __init__(self, cfg: Dict[str, Any] = None):
|
| 550 |
+
self.cfg = cfg
|
| 551 |
+
|
| 552 |
+
def _init_ui(self):
|
| 553 |
+
NotImplemented
|
| 554 |
+
|
| 555 |
+
def call(self, **kwargs):
|
| 556 |
+
self._init_ui()
|
| 557 |
+
|
| 558 |
+
|
| 559 |
+
class AppSfmUI(AppBaseUI):
|
| 560 |
+
def __init__(self, cfg: Dict[str, Any] = None):
|
| 561 |
+
super().__init__(cfg)
|
| 562 |
+
self.matchers = None
|
| 563 |
+
self.features = None
|
| 564 |
+
self.global_features = None
|
| 565 |
+
|
| 566 |
+
def _update_options(self, option):
|
| 567 |
+
if option == "sparse":
|
| 568 |
+
return gr.Textbox("sparse", visible=True)
|
| 569 |
+
elif option == "dense":
|
| 570 |
+
return gr.Textbox("dense", visible=True)
|
| 571 |
+
else:
|
| 572 |
+
return gr.Textbox("not set", visible=True)
|
| 573 |
+
|
| 574 |
+
def set_local_features(self, features):
|
| 575 |
+
self.features = features
|
| 576 |
+
|
| 577 |
+
def set_global_features(self, features):
|
| 578 |
+
self.global_features = features
|
| 579 |
+
|
| 580 |
+
def set_matchers(self, matchers):
|
| 581 |
+
self.matchers = matchers
|
| 582 |
+
|
| 583 |
+
def _on_select_custom_params(self, value: bool = False):
|
| 584 |
+
return gr.Textbox(
|
| 585 |
+
label="Camera Params",
|
| 586 |
+
value="0,0,0,0",
|
| 587 |
+
interactive=value,
|
| 588 |
+
visible=value,
|
| 589 |
+
)
|
| 590 |
+
|
| 591 |
+
def _init_ui(self):
|
| 592 |
+
with gr.Row():
|
| 593 |
+
# data settting and camera settings
|
| 594 |
+
with gr.Column():
|
| 595 |
+
input_images = gr.File(
|
| 596 |
+
label="SfM", interactive=True, file_count="multiple"
|
| 597 |
+
)
|
| 598 |
+
# camera setting
|
| 599 |
+
with gr.Accordion("Camera Settings", open=True):
|
| 600 |
+
with gr.Column():
|
| 601 |
+
with gr.Row():
|
| 602 |
+
with gr.Column():
|
| 603 |
+
camera_model = gr.Dropdown(
|
| 604 |
+
choices=[
|
| 605 |
+
"PINHOLE",
|
| 606 |
+
"SIMPLE_RADIAL",
|
| 607 |
+
"OPENCV",
|
| 608 |
+
],
|
| 609 |
+
value="PINHOLE",
|
| 610 |
+
label="Camera Model",
|
| 611 |
+
interactive=True,
|
| 612 |
+
)
|
| 613 |
+
with gr.Column():
|
| 614 |
+
gr.Checkbox(
|
| 615 |
+
label="Shared Params",
|
| 616 |
+
value=True,
|
| 617 |
+
interactive=True,
|
| 618 |
+
)
|
| 619 |
+
camera_custom_params_cb = gr.Checkbox(
|
| 620 |
+
label="Custom Params",
|
| 621 |
+
value=False,
|
| 622 |
+
interactive=True,
|
| 623 |
+
)
|
| 624 |
+
with gr.Row():
|
| 625 |
+
camera_params = gr.Textbox(
|
| 626 |
+
label="Camera Params",
|
| 627 |
+
value="0,0,0,0",
|
| 628 |
+
interactive=False,
|
| 629 |
+
visible=False,
|
| 630 |
+
)
|
| 631 |
+
camera_custom_params_cb.select(
|
| 632 |
+
fn=self._on_select_custom_params,
|
| 633 |
+
inputs=camera_custom_params_cb,
|
| 634 |
+
outputs=camera_params,
|
| 635 |
+
)
|
| 636 |
+
|
| 637 |
+
with gr.Accordion("Matching Settings", open=True):
|
| 638 |
+
# feature extraction and matching setting
|
| 639 |
+
with gr.Row():
|
| 640 |
+
feature_type = gr.Radio(
|
| 641 |
+
["sparse", "dense"],
|
| 642 |
+
label="Feature Type",
|
| 643 |
+
value="sparse",
|
| 644 |
+
interactive=True,
|
| 645 |
+
)
|
| 646 |
+
feature_details = gr.Textbox(
|
| 647 |
+
label="Feature Details",
|
| 648 |
+
visible=False,
|
| 649 |
+
)
|
| 650 |
+
# feature_type.change(
|
| 651 |
+
# fn=self._update_options,
|
| 652 |
+
# inputs=feature_type,
|
| 653 |
+
# outputs=feature_details,
|
| 654 |
+
# )
|
| 655 |
+
# matcher setting
|
| 656 |
+
matcher_name = gr.Dropdown(
|
| 657 |
+
choices=self.matchers,
|
| 658 |
+
value="disk+lightglue",
|
| 659 |
+
label="Matching Model",
|
| 660 |
+
interactive=True,
|
| 661 |
+
)
|
| 662 |
+
with gr.Row():
|
| 663 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 664 |
+
with gr.Column():
|
| 665 |
+
|
| 666 |
+
with gr.Row():
|
| 667 |
+
# matching setting
|
| 668 |
+
max_features = gr.Slider(
|
| 669 |
+
label="Max Features",
|
| 670 |
+
minimum=100,
|
| 671 |
+
maximum=10000,
|
| 672 |
+
value=1000,
|
| 673 |
+
interactive=True,
|
| 674 |
+
)
|
| 675 |
+
ransac_threshold = gr.Slider(
|
| 676 |
+
label="Ransac Threshold",
|
| 677 |
+
minimum=0.01,
|
| 678 |
+
maximum=12.0,
|
| 679 |
+
value=4.0,
|
| 680 |
+
step=0.01,
|
| 681 |
+
interactive=True,
|
| 682 |
+
)
|
| 683 |
+
|
| 684 |
+
with gr.Row():
|
| 685 |
+
ransac_confidence = gr.Slider(
|
| 686 |
+
label="Ransac Confidence",
|
| 687 |
+
minimum=0.01,
|
| 688 |
+
maximum=1.0,
|
| 689 |
+
value=0.9999,
|
| 690 |
+
step=0.0001,
|
| 691 |
+
interactive=True,
|
| 692 |
+
)
|
| 693 |
+
ransac_max_iter = gr.Slider(
|
| 694 |
+
label="Ransac Max Iter",
|
| 695 |
+
minimum=1,
|
| 696 |
+
maximum=100,
|
| 697 |
+
value=100,
|
| 698 |
+
step=1,
|
| 699 |
+
interactive=True,
|
| 700 |
+
)
|
| 701 |
+
with gr.Accordion("Scene Graph Settings", open=True):
|
| 702 |
+
# mapping setting
|
| 703 |
+
scene_graph = gr.Dropdown(
|
| 704 |
+
choices=["all", "swin", "oneref"],
|
| 705 |
+
value="all",
|
| 706 |
+
label="Scene Graph",
|
| 707 |
+
interactive=True,
|
| 708 |
+
)
|
| 709 |
+
|
| 710 |
+
# global feature setting
|
| 711 |
+
global_feature = gr.Dropdown(
|
| 712 |
+
choices=self.global_features,
|
| 713 |
+
value="netvlad",
|
| 714 |
+
label="Global features",
|
| 715 |
+
interactive=True,
|
| 716 |
+
)
|
| 717 |
+
|
| 718 |
+
button_match = gr.Button("Run Matching", variant="primary")
|
| 719 |
+
|
| 720 |
+
# mapping setting
|
| 721 |
+
with gr.Column():
|
| 722 |
+
with gr.Accordion("Mapping Settings", open=True):
|
| 723 |
+
with gr.Row():
|
| 724 |
+
with gr.Accordion("Buddle Settings", open=True):
|
| 725 |
+
with gr.Row():
|
| 726 |
+
mapper_refine_focal_length = gr.Checkbox(
|
| 727 |
+
label="Refine Focal Length",
|
| 728 |
+
value=False,
|
| 729 |
+
interactive=True,
|
| 730 |
+
)
|
| 731 |
+
mapper_refine_principle_points = gr.Checkbox(
|
| 732 |
+
label="Refine Principle Points",
|
| 733 |
+
value=False,
|
| 734 |
+
interactive=True,
|
| 735 |
+
)
|
| 736 |
+
mapper_refine_extra_params = gr.Checkbox(
|
| 737 |
+
label="Refine Extra Params",
|
| 738 |
+
value=False,
|
| 739 |
+
interactive=True,
|
| 740 |
+
)
|
| 741 |
+
with gr.Accordion(
|
| 742 |
+
"Retriangluation Settings", open=True
|
| 743 |
+
):
|
| 744 |
+
gr.Textbox(
|
| 745 |
+
label="Retriangluation Details",
|
| 746 |
+
)
|
| 747 |
+
gr.Button("Run SFM", variant="primary")
|
| 748 |
+
model_3d = gr.Model3D()
|