Skip to content

About

Unsupervised anomalous sound detection using diffusion models for machine condition monitoring with a Gradio interface.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Anomalous Sound Detection (ASD) via Diffusion Models

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.

Model Details

  • 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:
    • bearing
    • fan
  • 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.

Web Interface

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!) Anomaly Output Normal Output

Project Structure

  • 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.

Setup & Execution

  1. Install dependencies: Ensure you have PyTorch, torchaudio, Gradio, and other required libraries installed.
  2. Run the Web UI:
    python app.py
    Access the UI at http://127.0.0.1:7860.

About

Unsupervised anomalous sound detection using diffusion models for machine condition monitoring with a Gradio interface.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages