Spaces:
Sleeping
Sleeping
from turtle import width | |
import streamlit as st | |
from pathlib import Path | |
from PIL import Image | |
from variables import MAPPING_LANG_CODE_TO_TEXT, PLOT_SIZES_PER_LANG | |
# Only need to set these here as we are add controls outside of Hydralit, to customise a run Hydralit! | |
st.set_page_config(page_title="Documents sizes", layout="wide") | |
plot_dir = Path("data/boxplot_per_ds_per_lang") | |
plot_paths = list(plot_dir.iterdir()) | |
plot_paths = sorted(plot_paths) | |
with st.sidebar: | |
st.write("Go to plot") | |
for plot_path in plot_paths: | |
plot_name = str(plot_path.name) | |
if plot_name == "colorbar.png": | |
continue | |
lang_id = plot_name.split("_")[1][:-len(".png")] | |
title = MAPPING_LANG_CODE_TO_TEXT[lang_id] | |
st.markdown(f"[{title}](#{title.replace(' ', '-').lower()})", unsafe_allow_html=True) | |
for plot_path in plot_paths: | |
plot_name = str(plot_path.name) | |
if plot_name == "colorbar.png": | |
continue | |
lang_id = plot_name.split("_")[1][:-len(".png")] | |
st.title(MAPPING_LANG_CODE_TO_TEXT[lang_id]) | |
image = Image.open(plot_path) | |
st.image(image, width=int(round(float(PLOT_SIZES_PER_LANG[lang_id]['width'])*50))) |