pushpinder06 commited on
Commit
5d7800c
·
verified ·
1 Parent(s): bc82045

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
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("waste_classification(Mobilenetv2).h5")
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
- # Use gr.Camera instead of gr.Image
24
  gr.Interface(
25
  fn=predict_from_webcam,
26
- inputs=gr.Image(shape=(224, 224), tool=None, type="pil", label="Capture Image from Webcam"),
27
  outputs="text",
28
  live=True,
29
  title="Live Waste Classifier",
30
- description="Click webcam icon and show a waste image to classify."
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()