Spaces:
Running
Running
Update app.py
Browse files
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__), '
|
| 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 != (
|
| 18 |
-
image = np.resize(image, (
|
| 19 |
|
| 20 |
image = image / 255.0
|
| 21 |
image = np.expand_dims(image, axis=0)
|
| 22 |
|
| 23 |
prediction = model.predict(image)
|
| 24 |
-
class_label = '
|
| 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
|