Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| # Add this at the top of your script | |
| import warnings | |
| warnings.filterwarnings("ignore") | |
| import gradio as gr | |
| from data_loader import ( | |
| load_data, | |
| CATEGORIES, | |
| METHODOLOGY, | |
| HEADER_CONTENT, | |
| CARDS, | |
| DATASETS, | |
| SCORES, | |
| ) | |
| from tabs.leaderboard import create_leaderboard_tab, filter_leaderboard | |
| from tabs.model_comparison import create_model_comparison_tab, compare_models | |
| from tabs.data_exploration import create_exploration_tab, filter_and_display | |
| def create_app(): | |
| df = load_data() | |
| MODELS = [x.strip() for x in df["Model"].unique().tolist()] | |
| with gr.Blocks( | |
| theme=gr.themes.Soft(font=[gr.themes.GoogleFont("sans-serif")]) | |
| ) as app: | |
| with gr.Tabs(): | |
| # Create tabs | |
| lb_output, lb_plot1, lb_plot2 = create_leaderboard_tab( | |
| df, CATEGORIES, METHODOLOGY, HEADER_CONTENT, CARDS | |
| ) | |
| mc_info, mc_plot = create_model_comparison_tab(df, HEADER_CONTENT) | |
| exp_outputs = create_exploration_tab(df) | |
| # Initial loads | |
| app.load( | |
| fn=lambda: filter_leaderboard( | |
| df, "All", list(CATEGORIES.keys())[0], "Performance" | |
| ), | |
| outputs=[lb_output, lb_plot1, lb_plot2], | |
| ) | |
| app.load( | |
| fn=lambda: compare_models( | |
| df, [df.sort_values("Model Avg", ascending=False).iloc[0]["Model"]] | |
| ), | |
| outputs=[mc_info, mc_plot], | |
| ) | |
| app.load( | |
| fn=lambda: filter_and_display( | |
| MODELS[0], | |
| DATASETS[0], | |
| min(SCORES), | |
| max(SCORES), | |
| 0, | |
| 0, | |
| 0, | |
| ), | |
| outputs=exp_outputs[:-1], | |
| ) | |
| return app | |
| demo = create_app() | |
| demo.launch() | |