mandarmgd-03 commited on
Commit
21c8a2b
Β·
verified Β·
1 Parent(s): 9d8fd51

Update readme.md

Browse files
Files changed (1) hide show
  1. readme.md +67 -76
readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # πŸŒ€ Washing-Machine Sound Classifier
2
 
3
  This project implements a **two-stage hierarchical deep learning system** that classifies washing-machine sounds as **Normal** or **Abnormal**, and further identifies the **sub-class** (e.g., wash mode, spin mode, dehydration noise, bearing noise, etc.) using **Mel-spectrograms** and **CNN models**.
4
 
@@ -12,79 +12,71 @@ The project contains:
12
 
13
  ---
14
 
15
- ## πŸ“‚ Project Structure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- β”œβ”€β”€ app.py # Gradio web app for prediction
18
-
19
- β”œβ”€β”€ dl.py # Training script (CNN models for Stage 1 + subclasses)
20
-
21
- β”œβ”€β”€ extractaudio.py # Script for testing audio files
22
-
23
- β”œβ”€β”€ main_audio.py # Dependencies list (duplicated from requirements)
24
-
25
- β”œβ”€β”€ requirements.txt # Project dependencies
26
-
27
- β”œβ”€β”€ dl.py # Data pipeline for spectrograms
28
-
29
- β”œβ”€β”€ MelSpectrograms/ # Generated spectrogram dataset
30
-
31
- β”‚ β”œβ”€β”€ 00 - Abnormal/
32
-
33
- β”‚ β”‚ β”œβ”€β”€ Bearing noise/
34
-
35
- β”‚ β”‚ β”œβ”€β”€ Dehydration mode noise/
36
-
37
- β”‚ └── 01 - Normal/
38
-
39
- β”‚ β”œβ”€β”€ Wash mode/
40
-
41
- β”‚ β”œβ”€β”€ Spin mode/
42
-
43
- └── saved_models/ # Saved trained models (.h5) + label_meta.json
44
 
45
  ---
46
 
47
- ## βš™οΈ Installation
48
 
49
  1) Clone the repository and move into it:
50
  ```bash
51
  git clone <repo-url>
52
  cd washing-machine-classifier
 
53
  Create a virtual environment (recommended):
54
-
55
  python -m venv .venv
56
  source .venv/bin/activate # Linux/Mac
57
  .venv\Scripts\activate # Windows
 
58
 
59
  Install dependencies:
 
60
  pip install -r requirements.txt
 
61
 
62
  Data Preparation
63
  Place your raw audio dataset in the following structure:
64
 
65
- Washing machine/
66
-
67
- β”œβ”€β”€ 00 - Abnormal/
68
-
69
- β”‚ β”œβ”€β”€ Bearing noise/
70
-
71
- β”‚ └── Dehydration mode noise/
72
-
73
- └── 01 - Normal/
74
-
75
- β”œβ”€β”€ Wash mode/
76
-
77
- └── Spin mode/
78
-
79
- Convert .wav files to Mel-Spectrograms:
80
-
81
  python dl.py
82
- This will generate the MelSpectrograms/ dataset.
 
83
 
84
  Training Models
85
  Run:
86
-
87
  python dl.py
 
88
  Trains Stage 1 model (Normal vs Abnormal).
89
 
90
  Trains Stage 2 models (sub-classes for Normal and Abnormal).
@@ -112,39 +104,42 @@ View prediction result and generated spectrogram in the browser.
112
 
113
  Example output:
114
 
115
- 🎯 Final Prediction: Normal β†’ Spin mode
116
-
117
- Confidence Scores:
118
- --------------------
119
- Stage 1 (Normal): 0.9876
120
- Stage 2 (Spin mode): 0.9451
121
- Model Details
122
- Input: Mel-spectrogram images (224x224x3)
123
 
124
- Backbone: Simple CNN (Conv2D + MaxPooling + Dense + Dropout)
125
 
126
- Stage 1: Normal vs Abnormal
 
 
127
 
128
- Stage 2: Sub-classification within Normal/Abnormal
129
-
130
- Loss: Sparse categorical cross-entropy
131
-
132
- Optimizer: Adam
133
 
134
- Metrics: Accuracy
135
 
136
- Future Improvements
137
- Replace simple CNN with MobileNetV2 / EfficientNet for better accuracy.
 
 
 
 
138
 
139
- Add data augmentation (noise injection, pitch/time shift).
 
 
 
140
 
141
- Deploy as a FastAPI service for production.
142
 
143
- Containerize with Docker.
 
 
 
 
144
 
145
- Requirements
146
- See requirements.txt:
147
 
 
 
148
  tensorflow
149
  librosa
150
  matplotlib
@@ -154,10 +149,6 @@ uvicorn[standard]
154
  python-multipart
155
  gradio
156
 
157
- πŸ‘¨β€πŸ’» Author
158
- Developed by Anvit – Washing-machine sound anomaly detection with hierarchical deep learning.
159
-
160
- ---
161
 
162
 
163
 
 
1
+ # Washing-Machine Sound Classifier
2
 
3
  This project implements a **two-stage hierarchical deep learning system** that classifies washing-machine sounds as **Normal** or **Abnormal**, and further identifies the **sub-class** (e.g., wash mode, spin mode, dehydration noise, bearing noise, etc.) using **Mel-spectrograms** and **CNN models**.
4
 
 
12
 
13
  ---
14
 
15
+ ## Project Structure
16
+
17
+ β”œβ”€β”€ app.py # Gradio web app for prediction
18
+ β”œβ”€β”€ dl.py # Training script (CNN models for Stage 1 + subclasses)
19
+ β”œβ”€β”€ extractaudio.py # Script for testing audio files
20
+ β”œβ”€β”€ main_audio.py # Dependencies list (duplicated from requirements)
21
+ β”œβ”€β”€ requirements.txt # Project dependencies
22
+ β”œβ”€β”€ data_pipeline.py # Data pipeline for spectrograms
23
+ β”œβ”€β”€ MelSpectrograms/ # Generated spectrogram dataset
24
+ β”‚ β”œβ”€β”€ 00-Abnormal/
25
+ β”‚ β”‚ β”œβ”€β”€ 00-1 - Background noise/
26
+ β”‚ β”‚ β”œβ”€β”€ 00-2 - Dehydration mode noise/
27
+ β”‚ β”‚ └── 00-3 - Wash mode noise/
28
+ β”‚ └── 01-Normal/
29
+ β”‚ β”œβ”€β”€ 01-1 - Background noise/
30
+ β”‚ β”œβ”€β”€ 01-2 - Dehydration mode noise/
31
+ β”‚ └── 01-3 - Wash mode noise/
32
+ └── saved_models/ # Saved trained models (.h5) + label_meta.json
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  ---
36
 
37
+ ## Installation
38
 
39
  1) Clone the repository and move into it:
40
  ```bash
41
  git clone <repo-url>
42
  cd washing-machine-classifier
43
+ ```
44
  Create a virtual environment (recommended):
45
+ ```bash
46
  python -m venv .venv
47
  source .venv/bin/activate # Linux/Mac
48
  .venv\Scripts\activate # Windows
49
+ ```
50
 
51
  Install dependencies:
52
+ ```bash
53
  pip install -r requirements.txt
54
+ ```
55
 
56
  Data Preparation
57
  Place your raw audio dataset in the following structure:
58
 
59
+ β”œβ”€β”€ Washing machine/ # Generated spectrogram dataset
60
+ β”‚ β”œβ”€β”€ 00-Abnormal/
61
+ β”‚ β”‚ β”œβ”€β”€ 00-1 - Background noise/
62
+ β”‚ β”‚ β”œβ”€β”€ 00-2 - Dehydration mode noise/
63
+ β”‚ β”‚ └── 00-3 - Wash mode noise/
64
+ β”‚ └── 01-Normal/
65
+ β”‚ β”œβ”€β”€ 01-1 - Background noise/
66
+ β”‚ β”œβ”€β”€ 01-2 - Dehydration mode noise/
67
+ β”‚ └── 01-3 - Wash mode noise/
68
+
69
+ Convert .wav files to Mel-Spectrograms
70
+ ```bash
 
 
 
 
71
  python dl.py
72
+ ```
73
+ This will generate the MelSpectrograms/dataset.
74
 
75
  Training Models
76
  Run:
77
+ ```bash
78
  python dl.py
79
+ ```
80
  Trains Stage 1 model (Normal vs Abnormal).
81
 
82
  Trains Stage 2 models (sub-classes for Normal and Abnormal).
 
104
 
105
  Example output:
106
 
107
+ 🎯 Final Prediction: 00-Abnormal β†’ 00-1 - Background noise
 
 
 
 
 
 
 
108
 
109
+ # Model Summary & Confidence Scores
110
 
111
+ ## Confidence Scores
112
+ - **Stage 1 (Normal vs Abnormal):** 0.9876
113
+ - **Stage 2 (Sub-class within Normal, e.g., Spin mode):** 0.9451
114
 
115
+ ---
 
 
 
 
116
 
117
+ ## Model Details
118
 
119
+ - **Input:** Mel-spectrogram images (`224Γ—224Γ—3`)
120
+ - **Backbone:** Simple CNN
121
+ - `Conv2D + ReLU β†’ MaxPooling`
122
+ - `Flatten β†’ Dense β†’ Dropout β†’ Dense β†’ Softmax`
123
+ - **Stage 1:** Normal vs Abnormal classification
124
+ - **Stage 2:** Sub-classification within Normal / Abnormal
125
 
126
+ ### Training
127
+ - **Loss:** Sparse Categorical Cross-Entropy
128
+ - **Optimizer:** Adam
129
+ - **Metrics:** Accuracy
130
 
131
+ ---
132
 
133
+ ## Future Improvements
134
+ - Replace simple CNN with **MobileNetV2** or **EfficientNet** for higher accuracy.
135
+ - Add **data augmentation**: noise injection, pitch/time shift, random time masking.
136
+ - Deploy as a **FastAPI** service for production.
137
+ - Containerize with **Docker** for easy deployment.
138
 
139
+ ---
 
140
 
141
+ ## Requirements
142
+ ```text
143
  tensorflow
144
  librosa
145
  matplotlib
 
149
  python-multipart
150
  gradio
151
 
 
 
 
 
152
 
153
 
154