|
import subprocess |
|
|
|
import gradio as gr |
|
|
|
|
|
def run_scripts(): |
|
try: |
|
|
|
subprocess.run( |
|
["python", "hub_datasets_by_language.py"], |
|
capture_output=True, |
|
text=True, |
|
check=True, |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
return "Scripts executed successfully! All plots have been updated." |
|
except subprocess.CalledProcessError as e: |
|
return f"Failed to execute scripts: {str(e.stderr)}" |
|
|
|
|
|
def create_app(): |
|
with gr.Blocks() as app: |
|
gr.Markdown( |
|
""" |
|
# Visualizing The Language Gap In The Hugging Face Hub |
|
|
|
The open-source community is creating more and more resources in languages other than English but there is still a huge gap. This Space showcases plots that can help visualize this gap in the case of Spanish and can easily be adapted to other languages. |
|
""" |
|
) |
|
|
|
gr.Markdown( |
|
""" |
|
## English vs Spanish Monolingual Datasets |
|
|
|
Note: We consider only **monolingual** resources in these plots, i.e. datasets and models that only contain data in one language. This is because *most* of the multilingual resources are usually machine-translated and we want to focus on original data. |
|
""" |
|
) |
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
gr.Image( |
|
value="plots/datasets_bar_plot_horizontal.png", |
|
label="Distribution of Datasets by Year (Horizontal)", |
|
show_label=True, |
|
show_download_button=True, |
|
show_share_button=True, |
|
) |
|
gr.Image( |
|
value="plots/datasets_stack_area_en_es.png", |
|
label="Cumulative Growth of Datasets (Stacked)", |
|
show_label=True, |
|
show_download_button=True, |
|
show_share_button=True, |
|
) |
|
with gr.Column(): |
|
gr.Image( |
|
value="plots/datasets_bar_plot_vertical.png", |
|
label="Distribution of Datasets by Year (Vertical)", |
|
show_label=True, |
|
show_download_button=True, |
|
show_share_button=True, |
|
) |
|
gr.Image( |
|
value="plots/datasets_time_series.png", |
|
label="Cumulative Growth of Datasets (Line)", |
|
show_label=True, |
|
show_download_button=True, |
|
show_share_button=True, |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with gr.Row(): |
|
update_button = gr.Button("Update Plots with Latest Data") |
|
output_label = gr.Label() |
|
|
|
gr.Markdown( |
|
""" |
|
## Adapt to other languages |
|
|
|
This Space is WIP and more languages and visuals will be included shortly. Meanwhile, you can clone the Space, adapt the code in the scripts and run it to generate plots for other languages. |
|
""" |
|
) |
|
|
|
gr.Markdown("## Citation") |
|
with gr.Accordion("Citation information", open=False): |
|
gr.Markdown( |
|
r""" |
|
If you use these plots or the code please cite: |
|
|
|
``` |
|
@misc{grandury2024gaphf, |
|
author = {María Grandury}, |
|
title = {Visualizing The Language Gap In The Hugging Face Hub}, |
|
year = {2024}, |
|
publisher = {Hugging Face}, |
|
howpublished = {\url{https://huggingface.co/spaces/mariagrandury/language-gap-in-hf-hub}}, |
|
} |
|
``` |
|
""" |
|
) |
|
|
|
update_button.click( |
|
fn=run_scripts, |
|
outputs=output_label, |
|
) |
|
|
|
return app |
|
|
|
|
|
app = create_app() |
|
app.launch() |
|
|