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
|
| 8 |
-
model = load_model("
|
| 9 |
class_names = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
|
| 10 |
|
| 11 |
# Prediction function
|
|
@@ -20,12 +20,11 @@ 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.
|
| 27 |
outputs="text",
|
| 28 |
-
live=True,
|
| 29 |
title="Live Waste Classifier",
|
| 30 |
-
description="
|
| 31 |
).launch()
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
+
# Load 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 |
+
# Use gr.Camera() for webcam input (Gradio 4.x)
|
| 24 |
gr.Interface(
|
| 25 |
fn=predict_from_webcam,
|
| 26 |
+
inputs=gr.Camera(type="pil"), # webcam input as PIL image
|
| 27 |
outputs="text",
|
|
|
|
| 28 |
title="Live Waste Classifier",
|
| 29 |
+
description="Point your webcam at waste material. The model will classify it live."
|
| 30 |
).launch()
|