IceKhoffi commited on
Commit
eb87c50
·
verified ·
1 Parent(s): c41f09f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - id
5
+ tags:
6
+ - poultry
7
+ - chicken
8
+ - animal-health
9
+ - vocalization-analysis
10
+ - early-disease-detection
11
+ - sound-classification
12
+ - pytorch
13
+ - Indonesia
14
+ datasets:
15
+ - IceKhoffi/chicken-health-behavior-multimodal
16
+ ---
17
+
18
+ # `Chicken Vocalization Classifier`
19
+
20
+ This model is designed for classifying chicken vocalizations into categories indicative of health status or environmental noise. It serves as a crucial audio-based component within the "Chicken Health & Behavior Detection" multimodal project, aiming to aid in the early detection of poultry diseases and the monitoring of farm conditions.
21
+
22
+ ## Model Description
23
+
24
+ The `chicken-vocalization-classifier` is a Convolutional Neural Network (CNN) built with PyTorch, designed to process Log-Mel Spectrogram representations of audio recordings. It categorizes chicken sounds into three classes: `Healthy`, `Noise`, and `Unhealthy`. This model can help identify abnormal vocalizations (e.g., coughing, distress calls) that might signal health issues, or distinguish between relevant chicken sounds and general farm noise.
25
+
26
+ ## Training Data
27
+
28
+ This model was trained using the "Poultry Vocalization Signal Dataset for Early Disease Detection".
29
+
30
+ ## Training Procedure
31
+
32
+ The model was implemented and trained using the PyTorch framework
33
+
34
+ * **Model Architecture:** The model, named `ModdifiedModel`, consists of a `features` extractor and a `classifier` head.
35
+ * **Features Extractor (Sequential):** Composed of three blocks, each containing a `Conv2d` layer, `BatchNorm2d`, `ReLU` activation, and `MaxPool2d`.
36
+ * Block 1: `Conv2d(1, 32, kernel_size=3)`, `BatchNorm2d(32)`, `ReLU()`, `MaxPool2d(2)`
37
+ * Block 2: `Conv2d(32, 64, kernel_size=3)`, `BatchNorm2d(64)`, `ReLU()`, `MaxPool2d(2)`
38
+ * Block 3: `Conv2d(64, 128, kernel_size=3)`, `BatchNorm2d(128)`, `ReLU()`, `MaxPool2d(2)`
39
+ * **Classifier (Sequential):** Contains a `Flatten` layer, two `Linear` layers, `Dropout`, and `ReLU` activation.
40
+ * `Linear(in_features=25088, out_features=256)`
41
+ * `Dropout(0.5)`
42
+ * `ReLU()`
43
+ * `Linear(in_features=256, out_features=3)` (for 3 classes)
44
+
45
+ * **Preprocessing:** Audio files are converted to Log-Mel Spectrograms using `librosa`.
46
+ * `SAMPLE_RATE = 22050` Hz
47
+ * Audio is sampled to approximately 1.5 seconds (`WAV_SIZE = int(1.5 * SAMPLE_RATE)`)
48
+ * `MEL_BANDS = 128`
49
+ * `N_FFT = 2648`
50
+ * `HOP_LENGTH = 256`
51
+
52
+ * **Data Splitting:** The dataset was split into training and testing sets using `train_test_split` with `test_size=0.2` and `random_state=27`
53
+ * **Loss Function:** `nn.CrossEntropyLoss()`
54
+ * **Optimizer:** `torch.optim.Adam` with a learning rate (`lr`) of `0.001`
55
+ * **Epochs:** The model was trained for `30` epochs
56
+ * **Batch Size:** Training was performed with a `batch_size` of `32`
57
+
58
+ ## Performance
59
+
60
+ The Modified model was evaluated on a test set.
61
+
62
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/67524d7300134bb0ad1503a7/hKRNactESnugCNA5abcQO.png)
63
+
64
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/67524d7300134bb0ad1503a7/ttLqWCRr-6L63pRZ5tasu.png)
65
+
66
+ ## How to Use
67
+
68
+ You can load this trained model's weights with PyTorch. For full usage examples, including audio preprocessing steps and inference, please refer to the `CHBD_Vocalization_Analysis.ipynb` notebook provided in this repository.
69
+
70
+ ```python
71
+ import torch
72
+ import torch.nn as nn
73
+
74
+ # Define the ModdifiedModel class
75
+ # (You will need to copy this class definition from the CHBD_Vocalization_Analysis.ipynb file)
76
+ class ModdifiedModel(nn.Module):
77
+ def __init__(self, num_classes=3):
78
+ super(ModdifiedModel, self).__init__()
79
+ # ... (copy the full model architecture definition here) ...
80
+
81
+ def forward(self, x):
82
+ # ... (copy the forward pass definition here) ...
83
+
84
+ # Instantiate the model
85
+ model = ModdifiedModel(num_classes=3)
86
+
87
+ # Define the path to your model weights
88
+ model_weights_path = ''
89
+
90
+ state_dict = torch.hub.load_state_dict_from_url(model_weights_path, map_location='cpu')
91
+ model.load_state_dict(state_dict)
92
+
93
+ # Set model to evaluation mode
94
+ model.eval()
95
+
96
+ # The model is now loaded and ready for inference.
97
+ # Refer to the provided .ipynb for detailed preprocessing and inference examples.