@@ -177,6 +177,84 @@ Optional arguments:
177177- ` --output-dir ` : Output directory for results (default: auto-generated with timestamp)
178178- ` --seed ` : Random seed for reproducibility (default: 42)
179179
180+ ### Gradio Web Interface
181+
182+ The project includes a Gradio web interface for interactive AI audio detection. You can run it locally or deploy it to Modal.
183+
184+ #### Running Locally
185+
186+ To run the Gradio app locally with a PyTorch model:
187+
188+ ``` bash
189+ python gradio_app.py \
190+ --model model/saved_models/your_model.pth \
191+ [--threshold 0.35] \
192+ [--onnx]
193+ ```
194+
195+ To run with an ONNX model:
196+
197+ ``` bash
198+ python gradio_app.py \
199+ --model model/saved_models/your_model.onnx \
200+ --onnx \
201+ [--threshold 0.35]
202+ ```
203+
204+ Required arguments:
205+ - ` --model ` : Path to your trained model (.pth for PyTorch or .onnx for ONNX)
206+
207+ Optional arguments:
208+ - ` --threshold ` : Threshold for AI detection (default: 0.35)
209+ - ` --onnx ` : Use ONNX model instead of PyTorch (required if model is .onnx)
210+
211+ The app will launch at ` http://127.0.0.1:7860 ` by default.
212+
213+ ** Features:**
214+ - ** Single File Upload** : Upload one audio file (.mp3, .wav, .flac, .m4a) for instant prediction
215+ - ** Batch Processing** : Upload a ZIP file containing multiple audio files
216+ - Results include AI detection confidence and music analysis (genre, mood, tempo, energy)
217+ - Batch processing shows interactive tables, charts, and summary statistics
218+ - Download full results as CSV/Excel for further analysis
219+
220+ #### Deploying to Modal
221+
222+ The Gradio app can be deployed to Modal for cloud hosting. The deployed app uses ONNX models for optimized inference.
223+
224+ ** Prerequisites:**
225+ 1 . Install Modal CLI:
226+ ``` bash
227+ pip install modal
228+ ```
229+
230+ 2 . Authenticate with Modal:
231+ ``` bash
232+ modal token new
233+ ```
234+
235+ 3 . Convert your PyTorch model to ONNX (if not already done):
236+ ``` bash
237+ python scripts/setup_modal.py \
238+ --pth-path model/saved_models/your_model.pth \
239+ --onnx-path model/saved_models/your_model.onnx
240+ ```
241+
242+ 4 . Upload the ONNX model to Modal volume:
243+ ``` bash
244+ modal volume put ai-audio-models model/saved_models/your_model.onnx model.onnx
245+ ```
246+
247+ ** Deploy to Modal:**
248+ ``` bash
249+ modal deploy gradio_app.py
250+ ```
251+
252+ ** Access the deployed app:**
253+ Once deployed, your app will be available at:
254+ - ** URL** : https://sumerjoshi--ai-audio-detection-gradio-app-modal.modal.run/
255+
256+ ** Note:** The Modal deployment uses ONNX models for better performance and compatibility. Make sure you've uploaded your ONNX model to the ` ai-audio-models ` volume before deploying.
257+
180258## Project Structure
181259
182260```
@@ -204,6 +282,7 @@ audio-processing-ai/
204282├── train.py # Training script
205283├── predict.py # Prediction script
206284├── evaluation_pipeline.py # Model evaluation script
285+ ├── gradio_app.py # Gradio web interface (local and Modal deployment)
207286├── pyproject.toml # Package configuration
208287├── uv.lock # uv lock file (if using uv)
209288├── .pre-commit-config.yaml # Pre-commit hooks configuration
0 commit comments