From 83ddb9321f2a79845bd5f398673f035e2b364400 Mon Sep 17 00:00:00 2001 From: LashaO Date: Fri, 21 Apr 2023 16:11:56 +0400 Subject: [PATCH] Add new plugin integration --- _dev/super_setup.py | 1 + devops/Dockerfile | 10 +++++++++- devops/provision/Dockerfile | 4 +++- requirements/runtime.txt | 2 ++ wbia/algo/graph/mixin_matching.py | 30 ++++++++++++++++++++++++++++++ wbia/control/IBEISControl.py | 5 +++++ wbia/scripts/specialdraw.py | 2 ++ wbia/viz/viz_matches.py | 2 ++ wbia/web/apis_query.py | 3 +++ 9 files changed, 57 insertions(+), 2 deletions(-) diff --git a/_dev/super_setup.py b/_dev/super_setup.py index f4983ec012..d258b1f68f 100755 --- a/_dev/super_setup.py +++ b/_dev/super_setup.py @@ -36,6 +36,7 @@ ('WildMeOrg/wbia-plugin-pie', 'wbia-plugin-pie', 'develop'), ('WildMeOrg/wbia-plugin-pie-v2', 'wbia-plugin-pie-v2', 'develop'), ('WildMeOrg/wbia-plugin-lca', 'wbia-plugin-lca', 'develop'), + ('WildMeOrg/wbia-plugin-tbd', 'wbia-plugin-tbd', 'develop'), # ('WildMeOrg/wbia-plugin-2d-orientation', 'wbia-plugin-2d-orientation', 'develop'), ] diff --git a/devops/Dockerfile b/devops/Dockerfile index 9121835a26..180f4edf36 100644 --- a/devops/Dockerfile +++ b/devops/Dockerfile @@ -133,6 +133,14 @@ RUN set -ex \ && /virtualenv/env3/bin/pip uninstall -y \ nvidia_cublas_cu11 +# RUN set -ex \ +# && /virtualenv/env3/bin/pip install \ +# timm==0.6.12 + +# RUN set -ex \ +# && /virtualenv/env3/bin/pip install \ +# albumentations==1.3.0 + # Run smoke tests RUN set -ex \ && mkdir -p /data \ @@ -173,4 +181,4 @@ FROM org.wildme.wbia.install as org.wildme.wbia.depricated COPY ./_config/deprecated.sh /bin/deprecated -RUN if [ "$(uname -m)" != "aarch64" ] ; then deprecated ; fi +#RUN if [ "$(uname -m)" != "aarch64" ] ; then deprecated ; fi diff --git a/devops/provision/Dockerfile b/devops/provision/Dockerfile index 169b60d8bf..58030dcb46 100644 --- a/devops/provision/Dockerfile +++ b/devops/provision/Dockerfile @@ -39,7 +39,9 @@ RUN set -ex \ && git clone https://github.com/WildMeOrg/wbia-plugin-flukematch.git \ && git clone https://github.com/WildMeOrg/wbia-plugin-finfindr.git \ && git clone https://github.com/WildMeOrg/wbia-plugin-deepsense.git \ - && git clone https://github.com/WildMeOrg/wbia-plugin-pie-v2.git + && git clone https://github.com/WildMeOrg/wbia-plugin-pie-v2.git \ + && git clone https://github.com/WildMeOrg/wbia-plugin-tbd.git + RUN set -ex \ && cd /wbia \ diff --git a/requirements/runtime.txt b/requirements/runtime.txt index c38d2fb378..2870111faa 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -75,6 +75,8 @@ sqlalchemy==1.4.14 SQLAlchemy-Utils==0.38.3 tensorboard_logger==0.1.0 Theano==1.0.5 +timm==0.6.12 +albumentations==1.3.0 torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 diff --git a/wbia/algo/graph/mixin_matching.py b/wbia/algo/graph/mixin_matching.py index 942e0efd71..5a66a37452 100644 --- a/wbia/algo/graph/mixin_matching.py +++ b/wbia/algo/graph/mixin_matching.py @@ -219,6 +219,36 @@ def _make_rankings( edges = set(edges) return edges # + # + if cfgdict.get('pipeline_root', None) in ['Tbd']: + from wbia_tbd._plugin import distance_to_score + + globals().update(locals()) + + edges = [] + + for qaid in tqdm.tqdm(qaids): + daids_ = list(set(daids) - {qaid}) + tbd_annot_distances = ibs.tbd_predict_light_distance( + qaid, + daids_, + ) + score_list = [ + distance_to_score(tbd_annot_distance, norm=500.0) + for tbd_annot_distance in tbd_annot_distances + ] + values = sorted(zip(score_list, daids_))[::-1] + keep = values[:ranks_top] + daid_list = ut.take_column(keep, 1) + for daid in daid_list: + u, v = (qaid, daid) + if v < u: + u, v = v, u + edges.append((u, v)) + + edges = set(edges) + return edges + # if batch_size is not None: qaids_chunks = list(ut.ichunks(qaids, batch_size)) diff --git a/wbia/control/IBEISControl.py b/wbia/control/IBEISControl.py index e99667d5ae..21183f8585 100644 --- a/wbia/control/IBEISControl.py +++ b/wbia/control/IBEISControl.py @@ -165,6 +165,11 @@ (('--no-pie-v2', '--nopiev2'), 'wbia_pie_v2._plugin'), ] +if ut.get_argflag('--tbd'): + AUTOLOAD_PLUGIN_MODNAMES += [ + (('--no-tbd', '--notbd'), 'wbia_tbd._plugin'), + ] + if ut.get_argflag('--blend'): AUTOLOAD_PLUGIN_MODNAMES += [ diff --git a/wbia/scripts/specialdraw.py b/wbia/scripts/specialdraw.py index c1b99f62c8..1b43cc3d71 100644 --- a/wbia/scripts/specialdraw.py +++ b/wbia/scripts/specialdraw.py @@ -297,6 +297,7 @@ def double_depcache_graph(): 'Deepsense': 'Deepsense Distance', 'Pie': 'Pie Distance', 'PieTwo': 'Pie v2 Distance', + 'Tbd': 'Tbd Distance', 'Finfindr': 'Finfindr Distance', 'Kaggle7': 'Kaggle7 Distance', 'KaggleSeven': 'Kaggle7 Distance', @@ -328,6 +329,7 @@ def double_depcache_graph(): 'Deepsense': 'deepsense_distance', 'Pie': 'pie_distance', 'PieTwo': 'pie_v2_distance', + 'Tbd': 'tbd_distance', 'Finfindr': 'finfindr_distance', 'Kaggle7': 'kaggle7_distance', 'KaggleSeven': 'kaggle7_distance', diff --git a/wbia/viz/viz_matches.py b/wbia/viz/viz_matches.py index a4996ae43e..78f1641a0f 100644 --- a/wbia/viz/viz_matches.py +++ b/wbia/viz/viz_matches.py @@ -51,6 +51,7 @@ def get_query_annot_pair_info( 'kaggleseven', 'pie', 'pietwo', + 'tbd' ] ) and getattr(qreq_, '_isnewreq', None): if ( @@ -99,6 +100,7 @@ def get_data_annot_pair_info( 'kaggleseven', 'pie', 'pietwo', + 'tbd' ] ) and getattr(qreq_, '_isnewreq', None): if ( diff --git a/wbia/web/apis_query.py b/wbia/web/apis_query.py index 636f3054f0..f8909092b6 100644 --- a/wbia/web/apis_query.py +++ b/wbia/web/apis_query.py @@ -452,6 +452,7 @@ def review_graph_match_html( 'kaggleseven', 'pie', 'pietwo', + 'tbd' ): cls = chip_match.AnnotMatch # ibs.depc_annot.requestclass_dict['BC_DTW'] else: @@ -586,6 +587,8 @@ def review_query_chips_test(**kwargs): query_config_dict = {'pipeline_root': 'Pie'} elif 'use_pie_v2' in request.args: query_config_dict = {'pipeline_root': 'PieTwo'} + elif 'use_tbd' in request.args: + query_config_dict = {'pipeline_root': 'Tbd'} else: query_config_dict = {} result_dict = ibs.query_chips_test(query_config_dict=query_config_dict)