import gradio as gr import papermill as pm def run_notebook(): try: # Execute the notebook pm.execute_notebook( "hub_datasets_by_language.ipynb", "hub_datasets_by_language_output.ipynb", # Save the output in a new notebook ) return "Notebook executed successfully!" except Exception as e: return f"Failed to execute notebook: {str(e)}" 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 a 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** datasets in these plots, i.e. datasets that only contain data in one language. This is because *most* of the multilingual datasets are usually machine-translated and we want to focus on original data. """ ) with gr.Row(): with gr.Column(): image1 = gr.Image( value="plots/bar_plot_horizontal.png", label="Bar Plot Horizontal", show_label=True, show_download_button=True, show_share_button=True, ) image2 = gr.Image( value="plots/bar_plot_vertical.png", label="Bar Plot Vertical", show_label=True, show_download_button=True, show_share_button=True, ) with gr.Column(): image3 = gr.Image( value="plots/stack_area.png", label="Stack Area", show_label=True, show_download_button=True, show_share_button=True, ) image4 = gr.Image( value="plots/time_series.png", label="Time Series", show_label=True, show_download_button=True, show_share_button=True, ) 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 notebook and run it to generate plots for other languages. """ ) run_button = gr.Button("Run Notebook") output_label = gr.Label() # Display the result of running the notebook run_button.click(run_notebook, outputs=output_label) 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}}, } ``` """ ) return app app = create_app() app.launch()