From b7c311077f4ce18071d2ab8cde9e90f6b3268266 Mon Sep 17 00:00:00 2001 From: almaz Date: Tue, 17 Dec 2024 18:16:40 +0100 Subject: [PATCH 01/16] test sdk branch --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0566262 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/supervisely/supervisely.git@bokeh-widget \ No newline at end of file From b86ce46a7028b826b321253af63dbb2b5c886e4f Mon Sep 17 00:00:00 2001 From: almaz Date: Tue, 17 Dec 2024 18:27:25 +0100 Subject: [PATCH 02/16] add bokeh widget --- src/main.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main.py b/src/main.py index a23c01e..1381225 100644 --- a/src/main.py +++ b/src/main.py @@ -24,6 +24,8 @@ Field, Progress, SelectDataset, + IFrame, + Bokeh, SelectDatasetTree, NotificationBox, ) @@ -169,12 +171,9 @@ def update_globals(new_dataset_ids): ### Embeddings Chart -chart = ScatterChart( - title=f"None", - xaxis_type="numeric", - height=600, -) -card_chart = Card(content=chart) +bokeh = Bokeh(plots=[], x_axis_visible=True, y_axis_visible=True, grid_visible=True) +bokeh_iframe = IFrame() +card_chart = Card(content=bokeh_iframe) labeled_image = LabeledImage() text = Text("no object selected") show_all_anns = False @@ -209,11 +208,10 @@ def toggle_ann(): show_image(cur_info, project_meta) -@chart.click -def on_click(datapoint: ScatterChart.ClickedDataPoint): +@bokeh.value_changed +def on_click(selected_idxs): global global_idxs_mapping, all_info_list, project_meta, is_marked, tag_meta - idx = global_idxs_mapping[datapoint.series_name][datapoint.data_index] - info = all_info_list[idx] + info = all_info_list[selected_idxs] if tag_meta is not None: tag = read_tag(info["image_id"], info["object_id"]) is_marked = bool(tag) @@ -385,9 +383,11 @@ def run(): obj_classes = list(set(all_info["object_cls"])) print(f"n_classes = {len(obj_classes)}") series, colors, global_idxs_mapping = run_utils.make_series(projections, all_info_list, project_meta) - chart.set_title(f"{model_name} {project_info.name} {projection_method} embeddings", send_changes=False) - chart.set_colors(colors, send_changes=False) - chart.set_series(series, send_changes=True) + x_coordinates = [i["x"] for i in series[0]["data"]] + y_coordinates = [i["y"] for i in series[0]["data"]] + plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) + bokeh.add_plots([plot]) + bokeh_iframe.set(bokeh.get_html_route_with_timestamp(), height="600px", width="100%") card_embeddings_chart.show() update_table() info_run.description += "Done!
" From 60dbd31f5c8c1bed872bf20d7ece1cbbb6173654 Mon Sep 17 00:00:00 2001 From: almaz Date: Tue, 17 Dec 2024 18:39:34 +0100 Subject: [PATCH 03/16] add bokeh==3.4.3 --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0566262..f599dca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -git+https://github.com/supervisely/supervisely.git@bokeh-widget \ No newline at end of file +git+https://github.com/supervisely/supervisely.git@bokeh-widget +bokeh==3.4.3 \ No newline at end of file From 73974ce292640673ad219bcd2fdf1496c7405138 Mon Sep 17 00:00:00 2001 From: almaz Date: Tue, 17 Dec 2024 18:43:01 +0100 Subject: [PATCH 04/16] bokeh verion 3.6.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f599dca..5105900 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ git+https://github.com/supervisely/supervisely.git@bokeh-widget -bokeh==3.4.3 \ No newline at end of file +bokeh==3.6.2 \ No newline at end of file From 8443c72d148d87e20b4c261544a1dbc42f96cb3a Mon Sep 17 00:00:00 2001 From: almaz Date: Tue, 17 Dec 2024 18:52:04 +0100 Subject: [PATCH 05/16] bokeh version 3.1.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5105900..9862e5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ git+https://github.com/supervisely/supervisely.git@bokeh-widget -bokeh==3.6.2 \ No newline at end of file +bokeh==3.1.1 \ No newline at end of file From 0a5f9ac5145cceb2666c8b1d7c81c973677bdc3e Mon Sep 17 00:00:00 2001 From: almaz Date: Tue, 17 Dec 2024 19:01:30 +0100 Subject: [PATCH 06/16] fix colors and coords --- src/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 1381225..195ec0e 100644 --- a/src/main.py +++ b/src/main.py @@ -383,8 +383,13 @@ def run(): obj_classes = list(set(all_info["object_cls"])) print(f"n_classes = {len(obj_classes)}") series, colors, global_idxs_mapping = run_utils.make_series(projections, all_info_list, project_meta) - x_coordinates = [i["x"] for i in series[0]["data"]] - y_coordinates = [i["y"] for i in series[0]["data"]] + + x_coordinates, y_coordinates, colors = [], [], [] + for s, color in zip(series, colors): + x_coordinates.extend([i["x"] for i in s["data"]]) + y_coordinates.extend([i["y"] for i in s["data"]]) + colors.extend([color] * len(s["data"])) + plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) bokeh.add_plots([plot]) bokeh_iframe.set(bokeh.get_html_route_with_timestamp(), height="600px", width="100%") From b4bb9b9b78b1b283ecd1524a5a87c495f07b375a Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 09:36:50 +0100 Subject: [PATCH 07/16] small fixes --- src/main.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main.py b/src/main.py index 195ec0e..66db400 100644 --- a/src/main.py +++ b/src/main.py @@ -211,14 +211,15 @@ def toggle_ann(): @bokeh.value_changed def on_click(selected_idxs): global global_idxs_mapping, all_info_list, project_meta, is_marked, tag_meta - info = all_info_list[selected_idxs] - if tag_meta is not None: - tag = read_tag(info["image_id"], info["object_id"]) - is_marked = bool(tag) - update_marked() - show_image(info, project_meta) - if btn_mark.is_hidden(): - btn_mark.show() + if len(selected_idxs) == 1: + info = all_info_list[selected_idxs[0]] + if tag_meta is not None: + tag = read_tag(info["image_id"], info["object_id"]) + is_marked = bool(tag) + update_marked() + show_image(info, project_meta) + if btn_mark.is_hidden(): + btn_mark.show() def update_marked(): @@ -382,17 +383,17 @@ def run(): # 6. Show chart obj_classes = list(set(all_info["object_cls"])) print(f"n_classes = {len(obj_classes)}") - series, colors, global_idxs_mapping = run_utils.make_series(projections, all_info_list, project_meta) + series, pre_colors, global_idxs_mapping = run_utils.make_series(projections, all_info_list, project_meta) x_coordinates, y_coordinates, colors = [], [], [] - for s, color in zip(series, colors): + for s, color in zip(series, pre_colors): x_coordinates.extend([i["x"] for i in s["data"]]) y_coordinates.extend([i["y"] for i in s["data"]]) colors.extend([color] * len(s["data"])) plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) bokeh.add_plots([plot]) - bokeh_iframe.set(bokeh.get_html_route_with_timestamp(), height="600px", width="100%") + bokeh_iframe.set(bokeh.get_html_route_with_timestamp(), height="650px", width="100%") card_embeddings_chart.show() update_table() info_run.description += "Done!
" From 4ca38ef953ac9f0c046a906cefa16c2aa20a1569 Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 09:38:34 +0100 Subject: [PATCH 08/16] attribute changed --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 66db400..dd026b6 100644 --- a/src/main.py +++ b/src/main.py @@ -393,7 +393,7 @@ def run(): plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) bokeh.add_plots([plot]) - bokeh_iframe.set(bokeh.get_html_route_with_timestamp(), height="650px", width="100%") + bokeh_iframe.set(bokeh.html_route_with_timestamp, height="650px", width="100%") card_embeddings_chart.show() update_table() info_run.description += "Done!
" From 0ef73f2d322c89a2551ed8f5a76c04d8ff695343 Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 09:52:17 +0100 Subject: [PATCH 09/16] clear Bokeh plot before adding new plot --- src/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.py b/src/main.py index dd026b6..950a001 100644 --- a/src/main.py +++ b/src/main.py @@ -392,6 +392,7 @@ def run(): colors.extend([color] * len(s["data"])) plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) + bokeh.clear() bokeh.add_plots([plot]) bokeh_iframe.set(bokeh.html_route_with_timestamp, height="650px", width="100%") card_embeddings_chart.show() From 73c99cc41e236432a49ef9bd94a5ab41355676bf Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 16:33:04 +0100 Subject: [PATCH 10/16] upgrade sdk version --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 9862e5d..0c33700 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ git+https://github.com/supervisely/supervisely.git@bokeh-widget +fastapi==0.109.0 bokeh==3.1.1 \ No newline at end of file From c08e1082aa34d69cda9b2643638da5b228e6da38 Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 16:50:39 +0100 Subject: [PATCH 11/16] upgrade dependencies --- dev_requirements.txt | 4 +++- docker/Dockerfile | 6 ++++-- requirements.txt | 3 --- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 requirements.txt diff --git a/dev_requirements.txt b/dev_requirements.txt index 9cf8c9f..8a1e022 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,6 +1,8 @@ -supervisely==6.72.170 +supervisely==6.73.258 transformers==4.33.2 timm==0.9.5 torch scikit-learn==1.3.1 umap-learn==0.5.4 +fastapi==0.109.0 +bokeh==3.1.1 \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 7239855..be2c492 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,5 +11,7 @@ RUN pip3 install transformers==4.33.2 timm==0.9.5 scikit-learn==1.3.1 umap-learn # Download metaclip base model RUN python -c 'import transformers; transformers.AutoModel.from_pretrained("facebook/metaclip-b16-fullcc2.5b")' -RUN pip3 install supervisely==6.73.170 -LABEL python_sdk_version=6.73.170 +RUN pip3 install supervisely==6.73.258 +RUN pip3 install fastapi==0.109.0 bokeh==3.1.1 + +LABEL python_sdk_version=6.73.258 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 0c33700..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -git+https://github.com/supervisely/supervisely.git@bokeh-widget -fastapi==0.109.0 -bokeh==3.1.1 \ No newline at end of file From 1aa27c0eb0791a71855f18473ae2562bcda43e7b Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 17:17:57 +0100 Subject: [PATCH 12/16] Update docker image and instance version in config.json --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 8292ca2..0daef65 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "name": "Explore data with embeddings", "description": "Calculate and visualize embeddings", "entrypoint": "python -m uvicorn src.main:app --host 0.0.0.0 --port 8000", - "docker_image": "supervisely/embeddings_app:1.0.2", + "docker_image": "supervisely/embeddings_app:1.0.3", "port": 8000, "icon": "https://user-images.githubusercontent.com/115161827/211832834-eef9325d-9e00-4499-ae42-2e7ee3d97f1a.png", "icon_cover": true, @@ -26,7 +26,7 @@ "target": ["images_project", "images_dataset"], "context_category": "Metric Learning" }, - "instance_version": "6.11.10", + "instance_version": "6.12.12", "need_gpu": false, "gpu": "preferred", "community_agent": false From 679024edb37312eb48528fb0ed608dac62d5b11d Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 17:36:24 +0100 Subject: [PATCH 13/16] small changes --- src/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 950a001..5ec1705 100644 --- a/src/main.py +++ b/src/main.py @@ -211,7 +211,7 @@ def toggle_ann(): @bokeh.value_changed def on_click(selected_idxs): global global_idxs_mapping, all_info_list, project_meta, is_marked, tag_meta - if len(selected_idxs) == 1: + if len(selected_idxs) >= 1: info = all_info_list[selected_idxs[0]] if tag_meta is not None: tag = read_tag(info["image_id"], info["object_id"]) @@ -385,12 +385,16 @@ def run(): print(f"n_classes = {len(obj_classes)}") series, pre_colors, global_idxs_mapping = run_utils.make_series(projections, all_info_list, project_meta) + series_len = len(series) x_coordinates, y_coordinates, colors = [], [], [] for s, color in zip(series, pre_colors): x_coordinates.extend([i["x"] for i in s["data"]]) y_coordinates.extend([i["y"] for i in s["data"]]) colors.extend([color] * len(s["data"])) + r = 0.05 + if series_len > 1000: + r = 0.2 plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) bokeh.clear() bokeh.add_plots([plot]) From 2f82862d75624522ab57520152371273a0d649b7 Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 17:41:10 +0100 Subject: [PATCH 14/16] change points size --- src/main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.py b/src/main.py index 5ec1705..8bfcf76 100644 --- a/src/main.py +++ b/src/main.py @@ -392,10 +392,8 @@ def run(): y_coordinates.extend([i["y"] for i in s["data"]]) colors.extend([color] * len(s["data"])) - r = 0.05 - if series_len > 1000: - r = 0.2 - plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=0.05, colors=colors) + r = 0.2 if series_len > 1000 else 0.5 + plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=r, colors=colors) bokeh.clear() bokeh.add_plots([plot]) bokeh_iframe.set(bokeh.html_route_with_timestamp, height="650px", width="100%") From 816fcd0719435f242eeb3807d493391de42889c9 Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 17:43:50 +0100 Subject: [PATCH 15/16] Update point size based on series length --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 8bfcf76..fbca739 100644 --- a/src/main.py +++ b/src/main.py @@ -392,7 +392,7 @@ def run(): y_coordinates.extend([i["y"] for i in s["data"]]) colors.extend([color] * len(s["data"])) - r = 0.2 if series_len > 1000 else 0.5 + r = 0.1 if series_len > 1000 else 0.05 plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=r, colors=colors) bokeh.clear() bokeh.add_plots([plot]) From 14318bf806bda02c5c2ad55cebeffbeac6038e5b Mon Sep 17 00:00:00 2001 From: almaz Date: Wed, 18 Dec 2024 17:46:51 +0100 Subject: [PATCH 16/16] Update point size based on series length --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index fbca739..cf459fd 100644 --- a/src/main.py +++ b/src/main.py @@ -392,7 +392,7 @@ def run(): y_coordinates.extend([i["y"] for i in s["data"]]) colors.extend([color] * len(s["data"])) - r = 0.1 if series_len > 1000 else 0.05 + r = 0.15 if series_len > 1000 else 0.1 plot = Bokeh.Circle(x_coordinates, y_coordinates, radii=r, colors=colors) bokeh.clear() bokeh.add_plots([plot])