import streamlit as st from bokeh.plotting import figure from bokeh.models import ColumnDataSource, HoverTool, LinearColorMapper, ColorBar, BasicTicker from bokeh.transform import linear_cmap from bokeh.palettes import Viridis256 from datasets import load_dataset # Load the dataset dataset = load_dataset("tonyassi/revolve1-embeddings-xy")['train'] # Extract data data = { 'x': [item['x'] for item in dataset], 'y': [item['y'] for item in dataset], 'label': [f"ID: {item['id']}" for item in dataset], 'image': [item['image_url'] for item in dataset], 'id': [item['id'] for item in dataset] # Include 'id' for color mapping } source = ColumnDataSource(data=data) # Create a color mapper with reversed palette color_mapper = linear_cmap(field_name='id', palette=Viridis256[::-1], low=0, high=len(data['id'])) # Create the figure p = figure(title="Image Similarity Data Visualization", tools="pan,box_zoom,wheel_zoom,zoom_in,zoom_out,save,reset,hover", active_scroll="wheel_zoom", width=1500, height=1000, tooltips="""