bigscience-data/document-sizes
2
1from turtle import width2import streamlit as st3from pathlib import Path4from PIL import Image5 6from variables import MAPPING_LANG_CODE_TO_TEXT, PLOT_SIZES_PER_LANG7 8# Only need to set these here as we are add controls outside of Hydralit, to customise a run Hydralit!9st.set_page_config(page_title="Documents sizes", layout="wide")10 11plot_dir = Path("data/boxplot_per_ds_per_lang")12plot_paths = list(plot_dir.iterdir())13 14plot_paths = sorted(plot_paths)15 16with st.sidebar:17 st.write("Go to plot")18 for plot_path in plot_paths:19 plot_name = str(plot_path.name)20 if plot_name == "colorbar.png":21 continue22 lang_id = plot_name.split("_")[1][:-len(".png")]23 title = MAPPING_LANG_CODE_TO_TEXT[lang_id]24 st.markdown(f"[{title}](#{title.replace(' ', '-').lower()})", unsafe_allow_html=True)25 26for plot_path in plot_paths:27 plot_name = str(plot_path.name)28 if plot_name == "colorbar.png":29 continue30 lang_id = plot_name.split("_")[1][:-len(".png")]31 st.title(MAPPING_LANG_CODE_TO_TEXT[lang_id])32 image = Image.open(plot_path)33 st.image(image, width=int(round(float(PLOT_SIZES_PER_LANG[lang_id]['width'])*50)))