This project implements an unsupervised Anomalous Sound Detection (ASD) system using a Diffusion Model. The core objective is to detect anomalies in machine sounds without ever being trained on anomalous data. The system learns the distribution of "normal" operating sounds and flags any deviations during inference by measuring reconstruction errors.
- Architecture: Unet-based Gaussian Diffusion Model with partial diffusion reconstruction.
- Dataset: DCASE 2023 Task 2 (First Shot Unsupervised Anomalous Sound Detection for Machine Condition Monitoring).
- Trained Machines: The model has currently been fully trained and evaluated on two machine types:
bearingfan
- Inference Pipeline: The system corrupts incoming test audio with a specific amount of noise and uses the diffusion model to denoise it back to a "normal" state. The difference between the original audio and the AI's reconstruction is computed using an Anomaly Filter (AF) to generate a final anomaly score.
A Gradio-based web interface (app.py) is included to easily test the model. You can drag and drop .wav files into the UI to instantly see the anomaly score, the verdict (Normal vs. Anomaly), and a visual Mel-spectrogram comparison between the original audio and the model's reconstruction.
(Screenshots of the Normal and Anomaly web UI outputs will be added here!)

app.py: Gradio Web UI for interactive testing.train.py: The main training loop.diffusion.py: Core logic for the Gaussian Diffusion process (forward noise and DDIM reverse sampling).model.py: The UNet architecture.dataset.py: Audio loading, Mel-spectrogram extraction, and dataset grouping.evaluate.py: Evaluation pipeline to compute metrics.run_experiments.py: Orchestrator script to automate downloading data, training, and evaluating multiple machine types sequentially.
- Install dependencies: Ensure you have PyTorch, torchaudio, Gradio, and other required libraries installed.
- Run the Web UI:
Access the UI at
python app.py
http://127.0.0.1:7860.