vlithish commited on
Commit
c0795c6
·
verified ·
1 Parent(s): e327f54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -5,15 +5,12 @@ compostable = ["vegetable", "fruit", "food", "leaves"]
5
  recyclable = ["plastic", "paper", "glass", "metal", "bottle", "can"]
6
  harmful = ["syringe", "battery", "medical", "chemical"]
7
 
8
- def classify_waste(image):
9
  """
10
  Demo classifier based on the uploaded image filename.
11
- In a real app, you would use an ML model to classify the image.
12
  """
13
- # Get filename in lowercase
14
- filename = image.name.lower()
15
-
16
- # Simple filename-based rules for demo
17
  if any(word in filename for word in compostable):
18
  return "✅ Compostable Waste (Green Bin)"
19
  elif any(word in filename for word in recyclable):
@@ -21,12 +18,12 @@ def classify_waste(image):
21
  elif any(word in filename for word in harmful):
22
  return "⚠️ Harmful/Non-Decomposable Waste (Red Bin)"
23
  else:
24
- return "🚮 common Waste (Grey Bin)"
25
 
26
  # Gradio UI
27
  iface = gr.Interface(
28
  fn=classify_waste,
29
- inputs=gr.Image(type="file", label="Upload a photo of your waste item"),
30
  outputs="text",
31
  title="♻️ Eco-Friendly Waste Classifier (Image Upload)",
32
  description="Upload a photo of a waste item and see which bin it belongs to!"
@@ -41,3 +38,5 @@ if __name__ == "__main__":
41
 
42
 
43
 
 
 
 
5
  recyclable = ["plastic", "paper", "glass", "metal", "bottle", "can"]
6
  harmful = ["syringe", "battery", "medical", "chemical"]
7
 
8
+ def classify_waste(image_path):
9
  """
10
  Demo classifier based on the uploaded image filename.
11
+ In a real app, you would use an ML model to classify the image content.
12
  """
13
+ filename = image_path.lower()
 
 
 
14
  if any(word in filename for word in compostable):
15
  return "✅ Compostable Waste (Green Bin)"
16
  elif any(word in filename for word in recyclable):
 
18
  elif any(word in filename for word in harmful):
19
  return "⚠️ Harmful/Non-Decomposable Waste (Red Bin)"
20
  else:
21
+ return "🚮 General Waste (Grey Bin)"
22
 
23
  # Gradio UI
24
  iface = gr.Interface(
25
  fn=classify_waste,
26
+ inputs=gr.Image(type="filepath", label="Upload a photo of your waste item"), # FIXED here
27
  outputs="text",
28
  title="♻️ Eco-Friendly Waste Classifier (Image Upload)",
29
  description="Upload a photo of a waste item and see which bin it belongs to!"
 
38
 
39
 
40
 
41
+
42
+