Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,8 @@ from tensorflow.keras.preprocessing.image import img_to_array
|
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
-
# Load model
|
| 8 |
-
model = load_model("
|
| 9 |
class_names = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
|
| 10 |
|
| 11 |
# Prediction function
|
|
@@ -20,15 +20,12 @@ def predict_from_webcam(image):
|
|
| 20 |
|
| 21 |
return f"{predicted_class} ({confidence*100:.1f}%)"
|
| 22 |
|
| 23 |
-
#
|
| 24 |
gr.Interface(
|
| 25 |
fn=predict_from_webcam,
|
| 26 |
-
inputs=gr.Image(
|
| 27 |
outputs="text",
|
| 28 |
live=True,
|
| 29 |
title="Live Waste Classifier",
|
| 30 |
-
description="
|
| 31 |
-
)
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
interface.launch()
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
+
# Load the trained model
|
| 8 |
+
model = load_model("waste_classifier_model.h5")
|
| 9 |
class_names = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
|
| 10 |
|
| 11 |
# Prediction function
|
|
|
|
| 20 |
|
| 21 |
return f"{predicted_class} ({confidence*100:.1f}%)"
|
| 22 |
|
| 23 |
+
# Gradio interface with webcam input
|
| 24 |
gr.Interface(
|
| 25 |
fn=predict_from_webcam,
|
| 26 |
+
inputs=gr.Image(source="webcam", tool=None, type="pil"),
|
| 27 |
outputs="text",
|
| 28 |
live=True,
|
| 29 |
title="Live Waste Classifier",
|
| 30 |
+
description="Show waste to your webcam. This app predicts if it's paper, glass, plastic, etc."
|
| 31 |
+
).launch()
|
|
|
|
|
|
|
|
|