Spaces:
Runtime error
Runtime error
# %% | |
import pandas as pd | |
df = pd.read_csv("data.csv") | |
df | |
# %% | |
import gradio as gr | |
def sentence_builder(model, dataset, displayed_metrics): | |
row = df[df["friendly_name"] == model] | |
str = ( | |
f"## 🚧 Safety card\n" | |
f"Model: {model}\n" | |
f"Evaluating on dataset `{dataset}`" | |
) | |
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}`" | |
str += "\n<div style='text-align: right'>⛶ Expand safety card</div>" | |
return str | |
iface = gr.Interface( | |
sentence_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(["Accuracy", "Precision", "Recall", "Robustness", "Fairness"], value=["Accuracy", "Robustness"], 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"], | |
], | |
) | |
iface.launch() | |
# %% | |