Spaces:
Runtime error
Runtime error
| # %% | |
| import pandas as pd | |
| import gradio as gr | |
| df = pd.read_csv("./data.csv") | |
| def md_builder(model, dataset, displayed_metrics): | |
| row = df[df["friendly_name"] == model] | |
| str = ( | |
| f"## <span style='font-size: 16px;'>🚧 Performance and safety of <code style='font-weight: 400'>{model}</code></span>\n" | |
| f"On dataset `{dataset}`\n" | |
| ) | |
| if "Performance" in displayed_metrics: | |
| str += f"\nPerformance: `{row['performance'].values[0]}`" | |
| if "Accuracy" in displayed_metrics: | |
| str += f"\nAccuracy: `{row['accuracy'].values[0]}`" | |
| if "Precision" in displayed_metrics: | |
| str += f"\nPrecision: `{row['precision_weighted'].values[0]}`" | |
| if "Recall" in displayed_metrics: | |
| str += f"\nRecall: `{row['recall_weighted'].values[0]}`" | |
| if "Robustness" in displayed_metrics: | |
| str += f"\nRobustness: `{100-row['robustness'].values[0]}`" | |
| if "Fairness" in displayed_metrics: | |
| str += f"\nFairness: `{0}`" | |
| if "Failure Clusters" in displayed_metrics: | |
| cl_count = row['cluster_count'].values[0] | |
| str += f"\n<details><summary>Top failures: <code>{row['top_failure_cluster'].values[0]}</code> (+{cl_count - 1} others)</summary>(details for all {cl_count} clusters)</details>" | |
| str += "\n<div style='text-align: right'>⛶ Expand safety card</div>" | |
| return str | |
| iface = gr.Interface( | |
| md_builder, | |
| [ | |
| gr.Dropdown( | |
| list(df["friendly_name"]), | |
| label="Model", | |
| value="ViT", | |
| info="Select a model to use for testing.", | |
| ), | |
| gr.Dropdown( | |
| ["marmal88/skin_cancer"], | |
| value="marmal88/skin_cancer", | |
| label="Dataset", | |
| info="Select the sampling dataset to use for testing.", | |
| ), | |
| gr.CheckboxGroup( | |
| [ | |
| "Performance", | |
| "Accuracy", | |
| "Precision", | |
| "Recall", | |
| "Robustness", | |
| "Fairness", | |
| "Failure Clusters", | |
| ], | |
| value=["Accuracy", "Robustness", "Fairness", "Failure Clusters"], | |
| label="Metrics", | |
| info="Select displayed metrics.", | |
| ), | |
| # gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?"), | |
| # gr.Dropdown( | |
| # ["ran", "swam", "ate", "slept"], value=["swam", "slept"], multiselect=True, label="Activity", info="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl." | |
| # ), | |
| # gr.Checkbox(label="Morning", info="Did they do it in the morning?"), | |
| ], | |
| "markdown", | |
| examples=[ | |
| [ | |
| "ViT", | |
| "marmal88/skin_cancer", | |
| ["Accuracy", "Robustness", "Fairness", "Failure Clusters"], | |
| ], | |
| ], | |
| ) | |
| iface.launch() | |
| # %% | |