Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,21 +24,21 @@ bat_classifier_model.compile(optimizer=optimizer, loss='mse', metrics=['accuracy
|
|
24 |
# Load the saved model
|
25 |
bat_classifier_model = tf.keras.models.load_model("bat_classifier_model")
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
# Gradio interface function
|
28 |
def classify_bat(image):
|
29 |
processed_image = preprocess_image(image)
|
30 |
prediction = bat_classifier_model.predict(processed_image)[0]
|
31 |
-
class_names = ["
|
32 |
return {class_names[i]: float(prediction[i]) for i in range(len(class_names))}
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
return processed_image
|
40 |
|
41 |
-
# Gradio interface
|
42 |
-
inputs = gr.inputs.Image()
|
43 |
-
outputs = gr.outputs.Label(num_top_classes=4)
|
44 |
-
gr.Interface(fn=classify_bat, inputs=inputs, outputs=outputs).launch()
|
|
|
24 |
# Load the saved model
|
25 |
bat_classifier_model = tf.keras.models.load_model("bat_classifier_model")
|
26 |
|
27 |
+
# Preprocess the image
|
28 |
+
def preprocess_image(image):
|
29 |
+
processed_image = np.expand_dims(image, axis=0)
|
30 |
+
return processed_image
|
31 |
+
|
32 |
# Gradio interface function
|
33 |
def classify_bat(image):
|
34 |
processed_image = preprocess_image(image)
|
35 |
prediction = bat_classifier_model.predict(processed_image)[0]
|
36 |
+
class_names = ["Pipistrellus pygmaus", "Noctula nyctalus "]
|
37 |
return {class_names[i]: float(prediction[i]) for i in range(len(class_names))}
|
38 |
|
39 |
+
inputs = gr.inputs.Image(label="Upload an image")
|
40 |
+
outputs = gr.outputs.Label(num_top_classes=2, label="Classification")
|
41 |
+
|
42 |
+
gr.Interface(fn=classify_bat, inputs=inputs, outputs=outputs).launch()
|
43 |
+
|
|
|
44 |
|
|
|
|
|
|
|
|