Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,9 @@ import matplotlib.pyplot as plt
|
|
10 |
import librosa.display
|
11 |
from datetime import datetime
|
12 |
import random
|
13 |
-
from tensorflow.keras.preprocessing import image
|
|
|
|
|
14 |
import matplotlib
|
15 |
|
16 |
|
@@ -181,6 +183,8 @@ def model():
|
|
181 |
# Upload an MP3 audio file
|
182 |
with col1:
|
183 |
audio_file = st.file_uploader('Upload an MP3 audio file', type=['mp3'])
|
|
|
|
|
184 |
|
185 |
if audio_file is not None:
|
186 |
st.write('Processing...')
|
@@ -208,9 +212,14 @@ def model():
|
|
208 |
model = tf.keras.models.load_model(model_path)
|
209 |
|
210 |
# Load and preprocess the image
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
# Make a prediction
|
216 |
predicted_class_index = model.predict(img, verbose=1)
|
@@ -218,6 +227,7 @@ def model():
|
|
218 |
predicted_class = class_labels[predicted_class_index.argmax()]
|
219 |
|
220 |
# Display the predicted bird species
|
|
|
221 |
st.write('Predicted Bird Species:', predicted_class)
|
222 |
|
223 |
# create a Streamlit app
|
|
|
10 |
import librosa.display
|
11 |
from datetime import datetime
|
12 |
import random
|
13 |
+
from tensorflow.keras.preprocessing import image
|
14 |
+
from tensorflow.keras.preprocessing.image import load_img, img_to_array
|
15 |
+
|
16 |
import matplotlib
|
17 |
|
18 |
|
|
|
183 |
# Upload an MP3 audio file
|
184 |
with col1:
|
185 |
audio_file = st.file_uploader('Upload an MP3 audio file', type=['mp3'])
|
186 |
+
dropdown = st.selectbox('Select Actual Bird Species', class_labels.values())
|
187 |
+
|
188 |
|
189 |
if audio_file is not None:
|
190 |
st.write('Processing...')
|
|
|
212 |
model = tf.keras.models.load_model(model_path)
|
213 |
|
214 |
# Load and preprocess the image
|
215 |
+
# Load the image directly from the BytesIO object
|
216 |
+
image = load_img(image_buffer, target_size=(224, 224))
|
217 |
+
|
218 |
+
# Convert the image to a NumPy array
|
219 |
+
img_array = img_to_array(image)
|
220 |
+
|
221 |
+
# Expand the dimensions to make it compatible with your model
|
222 |
+
img = np.expand_dims(img_array, axis=0)
|
223 |
|
224 |
# Make a prediction
|
225 |
predicted_class_index = model.predict(img, verbose=1)
|
|
|
227 |
predicted_class = class_labels[predicted_class_index.argmax()]
|
228 |
|
229 |
# Display the predicted bird species
|
230 |
+
st.write('Actual Bird Species:', dropdown)
|
231 |
st.write('Predicted Bird Species:', predicted_class)
|
232 |
|
233 |
# create a Streamlit app
|