nehulagrawal commited on
Commit
adb8c13
1 Parent(s): 0f5b891

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +188 -0
  2. label.joblib +3 -0
  3. model.joblib +3 -0
README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Infant Cry Classifier
2
+
3
+ ## Table of Contents
4
+ 1. [Introduction](#introduction)
5
+ 2. [Problem Statement](#problem-statement)
6
+ 3. [Solution](#solution)
7
+ 4. [Importance and Need](#importance-and-need)
8
+ 5. [How It Works](#how-it-works)
9
+ 6. [How to Use This Model](#how-to-use-this-model)
10
+ 7. [Model Performance](#model-performance)
11
+ 8. [Limitations and Considerations](#limitations-and-considerations)
12
+ 9. [Future Developments](#future-developments)
13
+ 10. [Contributing](#contributing)
14
+ 11. [License](#license)
15
+ 12. [Acknowledgments](#acknowledgments)
16
+
17
+ ## Introduction
18
+
19
+ The Infant Cry Classifier is an advanced machine learning model designed to analyze and categorize different types of infant cries. This innovative tool aims to assist parents, caregivers, and healthcare professionals in understanding and responding to infants' needs more effectively.
20
+
21
+ ## Problem Statement
22
+
23
+ Interpreting an infant's cries can be challenging, especially for new parents or in high-stress situations. Babies communicate their needs primarily through crying, but distinguishing between different types of cries (e.g., hunger, discomfort, tiredness) can be difficult. This uncertainty can lead to:
24
+
25
+ 1. Increased stress for parents and caregivers
26
+ 2. Delayed response to the infant's needs
27
+ 3. Potential misinterpretation of the baby's requirements
28
+
29
+ ## Solution
30
+
31
+ Our Infant Cry Classifier addresses these challenges by:
32
+
33
+ 1. Analyzing audio recordings of infant cries
34
+ 2. Extracting relevant acoustic features
35
+ 3. Classifying the cry into predefined categories (e.g., belly pain, burping, discomfort, hunger, tiredness)
36
+
37
+ ## Importance and Need
38
+
39
+ ### 1. Enhanced Infant Care
40
+
41
+ By accurately identifying the reason behind an infant's cry, caregivers can respond more promptly and appropriately to the baby's needs. This can lead to:
42
+
43
+ - Improved infant comfort and well-being
44
+ - Reduced stress for both the infant and caregiver
45
+ - Better overall care and nurturing
46
+
47
+ ### 2. Medical Applications
48
+
49
+ In healthcare settings, the Infant Cry Classifier can be a useful diagnostic tool:
50
+
51
+ - Assisting pediatricians in identifying potential health issues
52
+ - Supporting early detection of certain conditions that may affect an infant's cry patterns
53
+ - Providing objective data to complement clinical observations
54
+
55
+ ### 3. Research Opportunities
56
+
57
+ This model opens up new avenues for research in:
58
+
59
+ - Infant communication and development
60
+ - Early childhood psychology
61
+ - Acoustic analysis of infant vocalizations
62
+
63
+ ## How It Works
64
+
65
+ 1. **Data Collection**: The model is trained on infant cry audio samples, carefully labeled with their corresponding causes.
66
+
67
+ 2. **Feature Extraction**: Advanced signal processing techniques are used to extract relevant acoustic features from the audio samples.
68
+
69
+ 3. **Machine Learning**: A sophisticated machine learning algorithm is employed to learn the patterns associated with different types of cries.
70
+
71
+ 4. **Classification**: When presented with a new audio sample, the model analyzes it and classifies it into one of the predefined categories.
72
+
73
+ ## How to Use This Model
74
+
75
+ ### Prerequisites
76
+
77
+ - Python 3.7 or higher
78
+ - Required libraries (install via pip):
79
+ ```
80
+ pip install numpy pandas scikit-learn joblib librosa
81
+ ```
82
+
83
+ ### Installation
84
+
85
+ 1. Clone this repository:
86
+ ```
87
+ git clone https://github.com/your-username/infant-cry-classifier.git
88
+ cd infant-cry-classifier
89
+ ```
90
+
91
+ 2. Download the pre-trained model files:
92
+ - `model.joblib`: The trained SVM model
93
+ - `label.joblib`: The label encoder used for cry categories
94
+
95
+ ### Usage
96
+
97
+ 1. Import the necessary libraries:
98
+
99
+ ```python
100
+ import joblib
101
+ import librosa
102
+ import numpy as np
103
+ ```
104
+
105
+ 2. Load the pre-trained model and label encoder:
106
+
107
+ ```python
108
+ model = joblib.load('model.joblib')
109
+ le = joblib.load('label.joblib')
110
+ ```
111
+
112
+ 3. Define the feature extraction function (make sure this matches the function used during training):
113
+
114
+ ```python
115
+ def extract_features(file_path):
116
+ try:
117
+ # Load audio file and extract features
118
+ y, sr = librosa.load(file_path, sr=16000)
119
+ mfcc = np.mean(librosa.feature.mfcc(y=y, sr=sr, n_mfcc=40,n_fft=n_fft,hop_length=hop_length,win_length=win_length,window=window).T,axis=0)
120
+ mel = np.mean(librosa.feature.melspectrogram(y=y, sr=sr,n_fft=n_fft, hop_length=hop_length, win_length=win_length, window='hann',n_mels=n_mels).T,axis=0)
121
+ stft = np.abs(librosa.stft(y))
122
+ chroma = np.mean(librosa.feature.chroma_stft(S=stft, y=y, sr=sr).T,axis=0)
123
+ contrast = np.mean(librosa.feature.spectral_contrast(S=stft, y=y, sr=sr,n_fft=n_fft,
124
+ hop_length=hop_length, win_length=win_length,
125
+ n_bands=n_bands, fmin=fmin).T,axis=0)
126
+ tonnetz =np.mean(librosa.feature.tonnetz(y=y, sr=sr).T,axis=0)
127
+ features = np.concatenate((mfcc, chroma, mel, contrast, tonnetz))
128
+ # print(shape(features))
129
+ return features
130
+ except:
131
+ print("Error: Exception occurred in feature extraction")
132
+ return None
133
+ ```
134
+
135
+ 4. Use the model to classify a new cry audio:
136
+
137
+ ```python
138
+ def predict_cry(file_path):
139
+ # Load the saved model and LabelEncoder
140
+ loaded_model = joblib.load('model.joblib')
141
+ loaded_le = joblib.load('label.joblib')
142
+
143
+ # Extract features from the new audio file
144
+ features = extract_features(file_path)
145
+
146
+ if features is not None:
147
+ # Reshape features to match the input shape expected by the model
148
+ features = features.reshape(1, -1)
149
+
150
+ # Make prediction
151
+ prediction = loaded_model.predict(features)
152
+
153
+ # Convert prediction back to original label
154
+ predicted_label = loaded_le.inverse_transform(prediction)
155
+
156
+ return predicted_label[0]
157
+ else:
158
+ return "Error: Could not extract features from the audio file"
159
+
160
+ # Example usage
161
+ file_path = 'path/to/your/file.wav'
162
+ result = predict_cry(file_path)
163
+ print(f"Predicted cry type: {result}")
164
+ ```
165
+
166
+ ### Integration
167
+
168
+ You can integrate this model into your own applications, such as:
169
+
170
+ - A mobile app for parents
171
+ - A monitoring system for nurseries
172
+ - A research tool for pediatric studies
173
+
174
+ ## License
175
+
176
+ This project is licensed under the MIT License - see the `LICENSE.md` file for details.
177
+
178
+ ## Acknowledgments
179
+
180
+ - Thanks to all the parents and caregivers who contributed audio samples
181
+ - Pediatric researchers who provided domain expertise
182
+ - Open-source community for various tools and libraries used in this project
183
+
184
+ ## Conclusion
185
+
186
+ The Infant Cry Classifier represents a significant step forward in leveraging technology to support infant care. By providing insights into an infant's needs through cry analysis, we aim to enhance the quality of care, reduce parental stress, and contribute to the overall well-being of infants and their caregivers.
187
+
188
+ We welcome feedback and contributions from the community to further improve and expand this important tool. Together, we can make a meaningful difference in the lives of infants and their families.
label.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a82740f73e162c78aa43903814af40bae174b3c9a84c1b823f282089e0ff9791
3
+ size 527
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c640cd82970f11fdd3db4147251b8fe7e28112968c1eca06532e1fca3c0aab2
3
+ size 113695