Spaces:
Sleeping
Sleeping
Commit ·
5588d0d
1
Parent(s): a7fe399
dataset tab receives links
Browse files
app.py
CHANGED
|
@@ -101,8 +101,11 @@ def predict(audio_path):
|
|
| 101 |
|
| 102 |
return label_map.get(str(pred), str(pred))
|
| 103 |
|
| 104 |
-
def evaluate_dataset():
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
y_true, y_pred = [], []
|
| 108 |
for row in ds:
|
|
@@ -121,11 +124,15 @@ def evaluate_dataset():
|
|
| 121 |
|
| 122 |
# Plot
|
| 123 |
fig, ax = plt.subplots(figsize=(5, 4))
|
| 124 |
-
sns.heatmap(
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
ax.set_xlabel("Predicted")
|
| 127 |
ax.set_ylabel("True")
|
| 128 |
-
ax.set_title("Confusion Matrix
|
| 129 |
plt.tight_layout()
|
| 130 |
|
| 131 |
return fig
|
|
@@ -142,9 +149,14 @@ with gr.Blocks() as demo:
|
|
| 142 |
live=False
|
| 143 |
)
|
| 144 |
with gr.Tab("Dataset Evaluation"):
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
eval_output = gr.Plot()
|
| 147 |
-
eval_btn.click(evaluate_dataset, inputs=
|
| 148 |
|
| 149 |
if __name__ == "__main__":
|
| 150 |
demo.launch()
|
|
|
|
| 101 |
|
| 102 |
return label_map.get(str(pred), str(pred))
|
| 103 |
|
| 104 |
+
def evaluate_dataset(repo_id):
|
| 105 |
+
try:
|
| 106 |
+
ds = load_dataset(repo_id, split="train")
|
| 107 |
+
except Exception as e:
|
| 108 |
+
return f"Could not load dataset: {e}"
|
| 109 |
|
| 110 |
y_true, y_pred = [], []
|
| 111 |
for row in ds:
|
|
|
|
| 124 |
|
| 125 |
# Plot
|
| 126 |
fig, ax = plt.subplots(figsize=(5, 4))
|
| 127 |
+
sns.heatmap(
|
| 128 |
+
cm, annot=True, fmt="d", cmap="Blues",
|
| 129 |
+
xticklabels=[label_map[str(l)] for l in labels],
|
| 130 |
+
yticklabels=[label_map[str(l)] for l in labels],
|
| 131 |
+
ax=ax
|
| 132 |
+
)
|
| 133 |
ax.set_xlabel("Predicted")
|
| 134 |
ax.set_ylabel("True")
|
| 135 |
+
ax.set_title(f"Confusion Matrix\n{repo_id}")
|
| 136 |
plt.tight_layout()
|
| 137 |
|
| 138 |
return fig
|
|
|
|
| 149 |
live=False
|
| 150 |
)
|
| 151 |
with gr.Tab("Dataset Evaluation"):
|
| 152 |
+
dataset_input = gr.Textbox(
|
| 153 |
+
label="Hugging Face Dataset ID",
|
| 154 |
+
value="karenlu653/dialect_model_demo", # default
|
| 155 |
+
placeholder="e.g. username/repo_name"
|
| 156 |
+
)
|
| 157 |
+
eval_btn = gr.Button("Run Evaluation")
|
| 158 |
eval_output = gr.Plot()
|
| 159 |
+
eval_btn.click(evaluate_dataset, inputs=dataset_input, outputs=eval_output)
|
| 160 |
|
| 161 |
if __name__ == "__main__":
|
| 162 |
demo.launch()
|