Spaces:
Configuration error
Configuration error
import gradio as gr from PIL import Image import random # ------------------------------- # Classification logic # ------------------------------- def classify_item(image, description): categories = ["Recyclable", "Compostable", "Trash", "Harmful"] if description: desc = description.lower() # Compostable: fruits & vegetables if "banana" in desc or "apple" in desc or "fruit" in desc or "vegetable" in desc or "food" in desc or "peel" in desc or "leaf" in desc: category = "Compostable" # Harmful: medical + batteries elif "syringe" in desc or "needle" in desc or "battery" in desc or
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
# -------------------------------
|
| 6 |
+
# Classification logic
|
| 7 |
+
# -------------------------------
|
| 8 |
+
def classify_item(image, description):
|
| 9 |
+
categories = ["Recyclable", "Compostable", "Trash", "Harmful"]
|
| 10 |
+
|
| 11 |
+
if description:
|
| 12 |
+
desc = description.lower()
|
| 13 |
+
|
| 14 |
+
# Compostable: fruits & vegetables
|
| 15 |
+
if "banana" in desc or "apple" in desc or "fruit" in desc or "vegetable" in desc or "food" in desc or "peel" in desc or "leaf" in desc:
|
| 16 |
+
category = "Compostable"
|
| 17 |
+
|
| 18 |
+
# Harmful: medical + batteries
|
| 19 |
+
elif "syringe" in desc or "needle" in desc or "battery" in desc or
|