Spaces:
Sleeping
Sleeping
update 2 train_speech
Browse files- src/train_speech.py +2 -2
src/train_speech.py
CHANGED
@@ -60,7 +60,7 @@ def load_audio_data(data_dir):
|
|
60 |
data.append({"path": file_path, "label": label_id})
|
61 |
return Dataset.from_list(data)
|
62 |
|
63 |
-
# Chargement du dataset
|
64 |
data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data"))
|
65 |
ds = load_audio_data(data_dir)
|
66 |
|
@@ -156,7 +156,7 @@ def train_classifier(feature_extractor, classifier, train_ds, test_ds, epochs=20
|
|
156 |
"classifier_state_dict": classifier.state_dict(),
|
157 |
"feature_extractor_state_dict": feature_extractor.state_dict(),
|
158 |
"processor": processor
|
159 |
-
}, "
|
160 |
print(f"✅ Nouveau meilleur modèle sauvegardé ! Accuracy: {best_accuracy:.4f}")
|
161 |
|
162 |
print(f"Epoch {epoch+1}/{epochs} - Loss: {total_loss/batch_count:.4f} - Accuracy: {train_acc:.4f}")
|
|
|
60 |
data.append({"path": file_path, "label": label_id})
|
61 |
return Dataset.from_list(data)
|
62 |
|
63 |
+
# Chargement du dataset
|
64 |
data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data"))
|
65 |
ds = load_audio_data(data_dir)
|
66 |
|
|
|
156 |
"classifier_state_dict": classifier.state_dict(),
|
157 |
"feature_extractor_state_dict": feature_extractor.state_dict(),
|
158 |
"processor": processor
|
159 |
+
}, "acc_model.pth")
|
160 |
print(f"✅ Nouveau meilleur modèle sauvegardé ! Accuracy: {best_accuracy:.4f}")
|
161 |
|
162 |
print(f"Epoch {epoch+1}/{epochs} - Loss: {total_loss/batch_count:.4f} - Accuracy: {train_acc:.4f}")
|