Skip to content

Commit

Permalink
add bokeh widget
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev committed Dec 17, 2024
1 parent b7c3110 commit b86ce46
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
Field,
Progress,
SelectDataset,
IFrame,
Bokeh,
SelectDatasetTree,
NotificationBox,
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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!<br>"
Expand Down

0 comments on commit b86ce46

Please sign in to comment.