https://github.com/lincolnhard/dog-bark-detector
Detect dog bark from spectrogram classification using sndfile-tools and darknet
https://github.com/lincolnhard/dog-bark-detector
aed cnn darknet dog spectrogram
Last synced: about 1 month ago
JSON representation
Detect dog bark from spectrogram classification using sndfile-tools and darknet
- Host: GitHub
- URL: https://github.com/lincolnhard/dog-bark-detector
- Owner: lincolnhard
- Created: 2018-09-20T05:44:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-21T06:46:33.000Z (over 6 years ago)
- Last Synced: 2025-01-03T10:56:48.824Z (4 months ago)
- Topics: aed, cnn, darknet, dog, spectrogram
- Language: C
- Size: 2.07 MB
- Stars: 28
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dogs - Dog Bark Detector
README
# dog-bark-detector
Detect dog bark from CNN based spectrogram classification
## Requirement
Dataset:
[Urbansound](https://urbansounddataset.weebly.com/urbansound.html) (training/testing set)
[ESC-50](https://github.com/karoldvl/ESC-50) (testing set)
[Freiburg 106](http://www.csc.kth.se/~jastork/pages/datasets.html) (training set, negative samples)3rdparty libraries:
[libsndfile](http://www.mega-nerd.com/libsndfile/#Download)
[fftw3](http://www.fftw.org/download.html)
[opencv](https://github.com/opencv/opencv)
[darknet](https://github.com/pjreddie/darknet)
[portaudio](http://www.portaudio.com/download.html)## Preprocessing
```
# To slice audio files into 2 secs duration clips, and store them into new .wav files
# Note that this will take up to 25 GB on your diskpython preprocessing.py --urbansound_dir [folder UrbanSound] --esc50_dir [folder ESC-50] --kitchen106_dir [folder building_106_kitchen/building_106_kitchen]
# Generate spectrograms
# Edit makefile, specify your darknet header/lib locationmake
./create_spectrogram [folder UrbanSound] [folder ESC-50] [folder building_106_kitchen/building_106_kitchen]
```## Training
Edit [Your darknet folder]/examples/classifier.c
In function **void train_classifier(...)**, change **args.type** from **CLASSIFICATION_DATA** to **OLD_CLASSIFICATION_DATA**, and rebuild darknet, since we don't want darknet augments input data for us.Edit **cfg/dogbark.data**, specify your training and validation set list.
```
# Training
./darknet classifier train cfg/dogbark.data cfg/dogbark.cfg
# Testing
./darknet classifier valid cfg/dogbark.data cfg/dogbark.test.cfg backup/dogbark.backup
```
#### Urbansound top-1 accuracy should be around 95%
#### ESC-50 Top-1 accuracy should be around 80%## Visualize
Test from file:
```
./classification_from_file [sound file] [win secs] [step secs] [export image height] [cfg file] [weights file]
# For example:
#./classification_from_file sound/dogtest.wav 2.8 0.1 200 cfg/dogbark.test.cfg weights/dogbark_32.weights
```
Test from microphone:
```
./classification_from_mic [win secs] [step secs] [export image height] [cfg file] [weights file]
# For example:
./classification_from_mic 2.5 0.02 200 cfg/dogbark.test.cfg weights/dogbark_32.weights
```