Spaces:
Sleeping
Sleeping
Strip /tmp/gradio prefix from CSV filename column
Browse files- helpers.py +7 -0
helpers.py
CHANGED
|
@@ -117,6 +117,13 @@ def run_inference(
|
|
| 117 |
ravens = sorted(out.glob(f"{wav_stem}-Raven-inference_results-*-{model_name}.txt"))
|
| 118 |
if not csvs:
|
| 119 |
raise RuntimeError(f"No CSV output produced for {wav_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
return csvs[-1], (ravens[-1] if ravens else None)
|
| 121 |
|
| 122 |
|
|
|
|
| 117 |
ravens = sorted(out.glob(f"{wav_stem}-Raven-inference_results-*-{model_name}.txt"))
|
| 118 |
if not csvs:
|
| 119 |
raise RuntimeError(f"No CSV output produced for {wav_path}")
|
| 120 |
+
# Rewrite the CSV's `filename` column to just the basename — the original
|
| 121 |
+
# value is the gradio temp upload path (/tmp/gradio/<hash>/...) which is
|
| 122 |
+
# noisy and useless to the user.
|
| 123 |
+
wav_basename = Path(wav_path).name
|
| 124 |
+
df = pd.read_csv(csvs[-1])
|
| 125 |
+
df["filename"] = wav_basename
|
| 126 |
+
df.to_csv(csvs[-1], index=False)
|
| 127 |
return csvs[-1], (ravens[-1] if ravens else None)
|
| 128 |
|
| 129 |
|