peshoet commited on
Commit
8070ff5
·
verified ·
1 Parent(s): 7a78f30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import numpy as np
4
  import os
5
 
6
  # Load the model (ensure it's in the same directory as app.py)
7
- model_path = os.path.join(os.path.dirname(__file__), 'waste_classifier_model.keras')
8
  model = load_model(model_path)
9
 
10
  # Prediction function
@@ -14,14 +14,14 @@ def classify_image(image):
14
 
15
  image = np.array(image)
16
 
17
- if image.shape != (128, 128, 3):
18
- image = np.resize(image, (128, 128, 3))
19
 
20
  image = image / 255.0
21
  image = np.expand_dims(image, axis=0)
22
 
23
  prediction = model.predict(image)
24
- class_label = 'Organic' if prediction[0][0] > 0.5 else 'Recycleable'
25
  return class_label
26
 
27
  # Create Gradio interface
 
4
  import os
5
 
6
  # Load the model (ensure it's in the same directory as app.py)
7
+ model_path = os.path.join(os.path.dirname(__file__), 'waste_classifier_mobilenetv2.h5')
8
  model = load_model(model_path)
9
 
10
  # Prediction function
 
14
 
15
  image = np.array(image)
16
 
17
+ if image.shape != (224, 224, 3):
18
+ image = np.resize(image, (224, 224, 3))
19
 
20
  image = image / 255.0
21
  image = np.expand_dims(image, axis=0)
22
 
23
  prediction = model.predict(image)
24
+ class_label = 'Reyclabble' if prediction[0][0] > 0.5 else 'Organic'
25
  return class_label
26
 
27
  # Create Gradio interface