Spaces:
Sleeping
Sleeping
Update app.py
Browse files3 unmodified lines45678910118 unmodified lines2021222324252627282930313233343 unmodified linesimport numpy as npfrom PIL import Image# Load modelmodel = load_model("waste_classification(Mobilenetv2).h5")class_names = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']# Prediction function8 unmodified linesreturn f"{predicted_class} ({confidence*100:.1f}%)"# Use gr.Camera instead of gr.Imagegr.Interface(fn=predict_from_webcam,inputs=gr.Image(shape=(224, 224), tool=None, type="pil", label="Capture Image from Webcam"),outputs="text",live=True,title="Live Waste Classifier",description="Click webcam icon and show a waste image to classify.")interface.launch()3 unmodified lines45678910118 unmodified lines2021222324252627282930313 unmodified linesimport numpy as npfrom PIL import Image# Load the trained modelmodel = load_model("waste_classifier_model.h5")class_names = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']# Prediction function8 unmodified linesreturn f"{predicted_class} ({confidence*100:.1f}%)"# Gradio interface with webcam inputgr.Interface(fn=predict_from_webcam,inputs=gr.Image(source="webcam", tool=None, type="pil"),outputs="text",live=True,title="Live Waste Classifier",description="Show waste to your webcam. This app predicts if it's paper, glass, plastic, etc.").launch()
app.py+6-9