Spaces:
Runtime error
Runtime error
File size: 2,902 Bytes
6b551f5 534a595 f6bcba8 00e8ae0 f6bcba8 a293aa3 a48afe6 6b551f5 9310588 6b551f5 9310588 6b551f5 a293aa3 6b551f5 f6bcba8 87823a5 a48afe6 f6bcba8 6b551f5 f6bcba8 6b551f5 f6bcba8 a293aa3 6b551f5 f6bcba8 6b551f5 f6bcba8 6b551f5 f6bcba8 a293aa3 6b551f5 f6bcba8 87823a5 534a595 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# %%
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()
# %%
|