Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- README.md +6 -5
- app.py +48 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
-
sdk_version: 1.40.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: images-data-vis-app
|
| 3 |
+
emoji: ๐๐ผ๏ธ
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: streamlit
|
| 7 |
+
sdk_version: 1.40.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from bokeh.plotting import figure
|
| 3 |
+
from bokeh.models import ColumnDataSource, HoverTool, LinearColorMapper, ColorBar, BasicTicker
|
| 4 |
+
from bokeh.transform import linear_cmap
|
| 5 |
+
from bokeh.palettes import Viridis256
|
| 6 |
+
from datasets import load_dataset
|
| 7 |
+
|
| 8 |
+
# Load the dataset
|
| 9 |
+
dataset = load_dataset('tonyassi/images-data-vis')['train']
|
| 10 |
+
|
| 11 |
+
# Extract data
|
| 12 |
+
data = {
|
| 13 |
+
'x': [item['x'] for item in dataset],
|
| 14 |
+
'y': [item['y'] for item in dataset],
|
| 15 |
+
'label': [f"ID: {item['id']}" for item in dataset],
|
| 16 |
+
'image': [item['image_url'] for item in dataset],
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
source = ColumnDataSource(data=data)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# Create the figure
|
| 23 |
+
p = figure(title="Image Similarity Data Visualization", tools="pan,box_zoom,wheel_zoom,zoom_in,zoom_out,save,reset,hover", active_scroll="wheel_zoom",
|
| 24 |
+
width=1500, height=1000, tooltips="""
|
| 25 |
+
<div>
|
| 26 |
+
<div><strong>@label</strong></div>
|
| 27 |
+
<div><img src="@image" ></div>
|
| 28 |
+
</div>
|
| 29 |
+
""")
|
| 30 |
+
p.circle('x', 'y', size=9, source=source) # Apply the color mapper
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
st.set_page_config(layout='wide')
|
| 34 |
+
|
| 35 |
+
st.markdown("""
|
| 36 |
+
# Image Similarity Data Visualization
|
| 37 |
+
|
| 38 |
+
This visualization was created with [ImSimVis](https://github.com/TonyAssi/ImSimVis).
|
| 39 |
+
|
| 40 |
+
Images can be previewed on hover. Images position are based on similarity, images close to each other look similar. The colors represent the best seller index. 0 is best seller. [Dataset](https://huggingface.co/datasets/tonyassi/images-data-vis).
|
| 41 |
+
""")
|
| 42 |
+
|
| 43 |
+
#st.html('<br><br><br><br>')
|
| 44 |
+
|
| 45 |
+
# Display the Bokeh figure in Streamlit
|
| 46 |
+
st.bokeh_chart(p,use_container_width=True)
|
| 47 |
+
|
| 48 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bokeh==2.4.3
|
| 2 |
+
numpy==1.23.1
|