Spaces:
Sleeping
Sleeping
File size: 2,323 Bytes
7f9536b f956fa7 07c7fb5 fc80367 7f9536b fdbdba1 23b7134 7f9536b 718f172 c39f4d0 fc80367 63ef6c3 f956fa7 66d0c64 63ef6c3 fdbdba1 63ef6c3 4c83c98 63ef6c3 4c83c98 63ef6c3 fabc384 63ef6c3 4c83c98 23b7134 fdbdba1 7d772e3 97d9f54 c39f4d0 97d9f54 23b7134 fdbdba1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
import streamlit as st
import dataset_wrangler, image_analysis
dataset = "https://raw.githubusercontent.com/StateLibraryVictoria/public-domain-hack-2024/refs/heads/ch4-data-viz/datasets/ch3_colour_data_viz_suggestions_set_2_augmented.csv"
palette_columns = ["pal_1", "pal_3", "pal_5"]
st.write(
"Scrambled Images from [https://www.slv.vic.gov.au/images](https://www.slv.vic.gov.au/images)"
)
df = dataset_wrangler.clean_df(dataset=dataset, subset=palette_columns)
df["created_year"] = df["Created - W 3 CDTF (DCTERMS)"].apply(
lambda x: dataset_wrangler.split_created_year(x)[0]
)
with st.form("my_form"):
# st.write("")
min_year = df["created_year"].min()
max_year = df["created_year"].max()
values = st.slider(
"Select a year range: ",
min_year,
max_year,
(min_year, max_year),
)
st.form_submit_button("Visualise my selection")
df = df[df["created_year"].between(values[0], values[1])]
random_selection = df.sample(n=3)
random_selection["iiif_url"] = random_selection["IE PID"].apply(
lambda x: image_analysis.get_iiif_image_urls(x)
)
col1, col2 = st.columns([0.3, 0.7])
with col1:
st.write(f"Random image selection")
# for img in random_selection["iiif_url"].values.tolist():
# st.image(img, use_container_width=True)
for img in random_selection.values.tolist():
iiif_url = img[-1][0]
title = img[2]
palette = image_analysis.get_colour_palette_iiif_image(iiif_url=iiif_url)
st.image(img, use_container_width=True, caption=title)
st.image(palette[0], use_container_width=True)
p = dataset_wrangler.create_grid(df)
with col2:
st.write(f"Plotting images from {values[0]} to {values[1]}")
st.bokeh_chart(p, use_container_width=True)
# # !
# df = dataset_wrangler.clean_df(dataset=dataset, subset=palette_columns)
# random_selection = df.sample()
# random_selection["iiif_url"] = random_selection["IE PID"].apply(
# lambda x: image_analysis.get_iiif_image_urls(x)
# )
# for img in random_selection.values.tolist():
# iiif_url = img[-1][0]
# title = img[2]
# palette = image_analysis.get_colour_palette_iiif_image(iiif_url=iiif_url)
# st.image(img, use_container_width=True, caption=title)
# st.image(palette[0], use_container_width=True)
|