vibha-mah commited on
Commit
f3ba4f6
1 Parent(s): ffa189d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
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 = ["Class 1", "Class 2", "Class 3", "Class 4"]
32
  return {class_names[i]: float(prediction[i]) for i in range(len(class_names))}
33
 
34
- # Preprocess the image
35
- def preprocess_image(image):
36
- # Add your preprocessing steps here
37
- processed_image = image # Placeholder for actual preprocessing
38
- processed_image = np.expand_dims(processed_image, axis=0)
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