You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-9Lines changed: 70 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,8 +80,8 @@ pytest tests/ -v
80
80
81
81
For the training step, I used this file from here [Link text][https://github.com/qiuqiangkong/audioset_tagging_cnn/blob/master/README.md] that is a 16khz model for inference to finetune against.
82
82
83
-
For the example here, I set up a data folder at the top level with /data/train/ai and /data/train/real
84
-
and would .mp3 and .wav files that I want to fintune against. I got the real data from
83
+
For the example here, I set up a data folder at the top level with `/data/train/ai` and `/data/train/real`
84
+
and would .mp3 and .wav files that I want to finetune against. I got the real data from
85
85
FMA [Link Text][https://github.com/mdeff/fma] for testing, and the AI generated data from
86
86
Facebook's Music Gen. There needs to be the word "ai" in the path of the ai folders and "real" in the
87
87
path to the real songs.
@@ -90,8 +90,8 @@ path to the real songs.
90
90
so gzip your file beforehand**
91
91
92
92
Steps:
93
-
1. First place files in audio-processing-ai/data/train (if you are going to finetune data against your model)
94
-
**All AI Files should go in the /data/train/ai and all of the real files goes in /data/train/real. This is because we need to do supervised learning befor training the classfier which file is AI music and which is Real**
93
+
1. First place files in `data/train/` (if you are going to finetune data against your model)
94
+
**All AI Files should go in `/data/train/ai` and all of the real files goes in `/data/train/real`. This is because we need to do supervised learning before training the classifier which file is AI music and which is Real**
95
95
2. Figure out the model you are going to finetune against
96
96
3. Update this line (PRETRAINED_MODEL_PATH = 'model/pretrained/pretrained_models/Cnn14_16k_mAP=0.438.pth.gz') at cnn14.py to the .pth.gz file location of your choice
97
97
@@ -114,28 +114,86 @@ Optional arguments:
114
114
115
115
### Inference
116
116
117
-
To run predictions on audio files:
117
+
Place your audio files in the `data/predict/` folder, then run predictions:
118
+
118
119
```bash
119
120
python predict.py \
120
-
--folder path/to/audio/files \
121
-
--model model/saved_models/your_model.pth
121
+
--folder data/predict \
122
+
--model model/saved_models/your_model.pth \
123
+
--output results
124
+
```
125
+
126
+
Or specify any folder containing audio files:
127
+
128
+
```bash
129
+
python predict.py \
130
+
--folder path/to/your/audio/files \
131
+
--model model/saved_models/your_model.pth \
132
+
--output results
122
133
```
123
134
124
135
Required arguments:
125
-
-`--folder`: Directory containing .mp3/.wav files to analyze
136
+
-`--folder`: Directory containing .mp3/.wav/.flac/.m4a files to analyze
126
137
-`--model`: Path to your trained model (.pth file)
138
+
-`--output`: Output directory for CSV and Excel results
127
139
128
140
The script will:
129
141
1. Process each audio file in the specified folder
130
142
2. Generate predictions for AI-generated content and audio scene tags
131
-
3. Save results to a CSV file named `predictions_YYYYMMDD_HHMM.csv`
143
+
3. Save results to a CSV file named `predictions_YYYYMMDD_HHMM.csv` and an Excel file with summary statistics
144
+
145
+
### Evaluation
146
+
147
+
To evaluate your trained model on a test set, use the `evaluation_pipeline.py` script. This will generate comprehensive metrics including ROC curves, confusion matrices, and threshold analysis.
148
+
149
+
**Prerequisites:**
150
+
- Your data should be split into train/val/test folders
151
+
- Test folder should contain `real/` and `ai/` subfolders with audio files
152
+
153
+
Example evaluation:
154
+
```bash
155
+
python evaluation_pipeline.py \
156
+
--model model/saved_models/your_model.pth \
157
+
--data-split data/split/ \
158
+
--output-dir evaluation_results
159
+
```
160
+
161
+
The evaluation will generate:
162
+
-`evaluation_plots.png`: ROC curve, logit distributions, threshold analysis, and confusion matrix
163
+
-`evaluation_thresholds.csv`: Performance metrics across different thresholds
164
+
-`evaluation_report.txt`: Detailed text report with all metrics
165
+
166
+
**Example Output:**
167
+
See `sample_runs/eval_sample_run/` for an example of evaluation results. This directory contains:
0 commit comments