Spaces:
Sleeping
Sleeping
Commit ·
d167b44
1
Parent(s): 9d36a99
Defensively skip malformed chord items (torch 2.8 shifts T5 sampling)
Browse files
app.py
CHANGED
|
@@ -147,9 +147,18 @@ class MusicFeaturePredictor:
|
|
| 147 |
|
| 148 |
predicted_chords, predicted_chords_times = [], []
|
| 149 |
for item in generated_chords:
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
predicted_chords.append(c)
|
| 152 |
-
predicted_chords_times.append(
|
| 153 |
|
| 154 |
return predicted_beats, predicted_chords, predicted_chords_times
|
| 155 |
|
|
|
|
| 147 |
|
| 148 |
predicted_chords, predicted_chords_times = [], []
|
| 149 |
for item in generated_chords:
|
| 150 |
+
parts = item.split(" at ")
|
| 151 |
+
if len(parts) != 2:
|
| 152 |
+
# Newer torch can shift T5 sampling and produce malformed items
|
| 153 |
+
# like 'Gm at 1.2 at 3.4'; skip them rather than crash.
|
| 154 |
+
continue
|
| 155 |
+
c, ct = parts
|
| 156 |
+
try:
|
| 157 |
+
ct_f = float(ct)
|
| 158 |
+
except ValueError:
|
| 159 |
+
continue
|
| 160 |
predicted_chords.append(c)
|
| 161 |
+
predicted_chords_times.append(ct_f)
|
| 162 |
|
| 163 |
return predicted_beats, predicted_chords, predicted_chords_times
|
| 164 |
|