Spaces:
Sleeping
Sleeping
Commit ·
e185fda
1
Parent(s): 47abb3e
Model prompt change
Browse files
app.py
CHANGED
|
@@ -89,40 +89,40 @@ def explain_recycling(class_label):
|
|
| 89 |
top_label = None
|
| 90 |
waste_analization = {
|
| 91 |
"cardboard": {
|
| 92 |
-
"Recycling type": "Paper/Cardboard recycling
|
| 93 |
-
"Disposal": "Flatten the cardboard boxes and remove any non-paper packing materials before placing them in the recycling bin.
|
| 94 |
-
"Tips": "Keep cardboard dry and clean to ensure it can be recycled efficiently.
|
| 95 |
-
"Extra": "Avoid using waxed or heavily coated cardboard, as it may not be recyclable.
|
| 96 |
},
|
| 97 |
"glass": {
|
| 98 |
-
"Recycling type": "Glass recycling
|
| 99 |
-
"Disposal": "Rinse glass bottles and jars, remove lids, and place them in a dedicated glass recycling container.
|
| 100 |
-
"Tips": "Avoid breaking the glass; broken pieces can be hazardous and may complicate processing.
|
| 101 |
-
"Extra": "Colored glass is often recycled separately; check local recycling rules.
|
| 102 |
},
|
| 103 |
"metal": {
|
| 104 |
-
"Recycling type": "Metal recycling
|
| 105 |
-
"Disposal": "Rinse aluminum cans and steel containers, remove labels if possible, and put them in the metal recycling bin.
|
| 106 |
-
"Tips": "Crush cans to save space and facilitate transport.
|
| 107 |
-
"Extra": "Avoid contaminating with food waste to improve recycling efficiency.
|
| 108 |
},
|
| 109 |
"paper": {
|
| 110 |
-
"Recycling type": "Paper recycling
|
| 111 |
-
"Disposal": "Sort newspapers, office paper, and magazines into the paper recycling bin; remove plastic coatings and staples.
|
| 112 |
-
"Tips": "Shred sensitive documents but keep shredded paper in a bag to avoid scattering.
|
| 113 |
-
"Extra": "Do not recycle wet or food-stained paper.
|
| 114 |
},
|
| 115 |
"plastic": {
|
| 116 |
-
"Recycling type": "Plastic recycling
|
| 117 |
-
"Disposal": "Rinse plastic bottles, containers, and packaging, and place them in the plastic recycling bin.
|
| 118 |
-
"Tips": "Check recycling codes; some plastics (like #3 PVC) are not widely recyclable.
|
| 119 |
-
"Extra": "Remove caps and labels when possible to improve sorting efficiency.
|
| 120 |
},
|
| 121 |
"trash": {
|
| 122 |
-
"Recycling type": "General waste / landfill
|
| 123 |
-
"Disposal": "Place non-recyclable items in the regular trash bin; avoid mixing with recyclables.
|
| 124 |
-
"Tips": "Separate hazardous materials like batteries, electronics, or chemicals for special disposal.
|
| 125 |
-
"Extra": "Try to reduce overall waste by reusing and composting when possible.
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
|
@@ -139,9 +139,15 @@ def analyze_pipeline():
|
|
| 139 |
if top_label is None:
|
| 140 |
return "Please classify an image first."
|
| 141 |
|
| 142 |
-
explanation = explain_recycling(top_label)
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
|
| 147 |
# ------------------ GRADIO UI ------------------
|
|
|
|
| 89 |
top_label = None
|
| 90 |
waste_analization = {
|
| 91 |
"cardboard": {
|
| 92 |
+
"Recycling type": "Paper/Cardboard recycling",
|
| 93 |
+
"Disposal": "Flatten the cardboard boxes and remove any non-paper packing materials before placing them in the recycling bin.",
|
| 94 |
+
"Tips": "Keep cardboard dry and clean to ensure it can be recycled efficiently.",
|
| 95 |
+
"Extra": "Avoid using waxed or heavily coated cardboard, as it may not be recyclable."
|
| 96 |
},
|
| 97 |
"glass": {
|
| 98 |
+
"Recycling type": "Glass recycling",
|
| 99 |
+
"Disposal": "Rinse glass bottles and jars, remove lids, and place them in a dedicated glass recycling container.",
|
| 100 |
+
"Tips": "Avoid breaking the glass; broken pieces can be hazardous and may complicate processing.",
|
| 101 |
+
"Extra": "Colored glass is often recycled separately; check local recycling rules."
|
| 102 |
},
|
| 103 |
"metal": {
|
| 104 |
+
"Recycling type": "Metal recycling",
|
| 105 |
+
"Disposal": "Rinse aluminum cans and steel containers, remove labels if possible, and put them in the metal recycling bin.",
|
| 106 |
+
"Tips": "Crush cans to save space and facilitate transport.",
|
| 107 |
+
"Extra": "Avoid contaminating with food waste to improve recycling efficiency."
|
| 108 |
},
|
| 109 |
"paper": {
|
| 110 |
+
"Recycling type": "Paper recycling",
|
| 111 |
+
"Disposal": "Sort newspapers, office paper, and magazines into the paper recycling bin; remove plastic coatings and staples.",
|
| 112 |
+
"Tips": "Shred sensitive documents but keep shredded paper in a bag to avoid scattering.",
|
| 113 |
+
"Extra": "Do not recycle wet or food-stained paper."
|
| 114 |
},
|
| 115 |
"plastic": {
|
| 116 |
+
"Recycling type": "Plastic recycling",
|
| 117 |
+
"Disposal": "Rinse plastic bottles, containers, and packaging, and place them in the plastic recycling bin.",
|
| 118 |
+
"Tips": "Check recycling codes; some plastics (like #3 PVC) are not widely recyclable.",
|
| 119 |
+
"Extra": "Remove caps and labels when possible to improve sorting efficiency."
|
| 120 |
},
|
| 121 |
"trash": {
|
| 122 |
+
"Recycling type": "General waste / landfill",
|
| 123 |
+
"Disposal": "Place non-recyclable items in the regular trash bin; avoid mixing with recyclables.",
|
| 124 |
+
"Tips": "Separate hazardous materials like batteries, electronics, or chemicals for special disposal.",
|
| 125 |
+
"Extra": "Try to reduce overall waste by reusing and composting when possible."
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
|
|
|
| 139 |
if top_label is None:
|
| 140 |
return "Please classify an image first."
|
| 141 |
|
| 142 |
+
# explanation = explain_recycling(top_label)
|
| 143 |
+
info = waste_analization[top_label]
|
| 144 |
+
result = (
|
| 145 |
+
f"• Recycling type: {info['Recycling type']}"
|
| 146 |
+
f"• Disposal: {info['Disposal']}"
|
| 147 |
+
f"• Tips: {info['Tips']}"
|
| 148 |
+
f"• Extra: {info['Extra']}"
|
| 149 |
+
)
|
| 150 |
+
return
|
| 151 |
|
| 152 |
|
| 153 |
# ------------------ GRADIO UI ------------------
|