Spaces:
Sleeping
Sleeping
Commit ·
92ae382
1
Parent(s): a746dfb
Analysis change
Browse files
app.py
CHANGED
|
@@ -157,176 +157,175 @@ def explain_recycling(class_label):
|
|
| 157 |
waste_analyzation_v1 = {
|
| 158 |
"paper/cardboard": {
|
| 159 |
"Recycling type": "Paper & Cardboard recycling",
|
| 160 |
-
"Disposal": "Flatten boxes and
|
| 161 |
-
"Tips": "
|
| 162 |
-
"Extra": "
|
| 163 |
},
|
| 164 |
"plastic": {
|
| 165 |
"Recycling type": "Plastic recycling",
|
| 166 |
-
"Disposal": "Rinse plastic containers and place
|
| 167 |
-
"Tips": "
|
| 168 |
-
"Extra": "Soft plastics
|
| 169 |
},
|
| 170 |
"glass": {
|
| 171 |
"Recycling type": "Glass recycling",
|
| 172 |
-
"Disposal": "Rinse glass bottles
|
| 173 |
-
"Tips": "Remove lids and caps
|
| 174 |
-
"Extra": "Broken glass may not be accepted in
|
| 175 |
},
|
| 176 |
"metal": {
|
| 177 |
"Recycling type": "Metal recycling",
|
| 178 |
-
"Disposal": "
|
| 179 |
-
"Tips": "Crushing cans
|
| 180 |
-
"Extra": "
|
| 181 |
},
|
| 182 |
"organic waste": {
|
| 183 |
"Recycling type": "Organic / compost waste",
|
| 184 |
-
"Disposal": "Place food scraps and
|
| 185 |
-
"Tips": "
|
| 186 |
-
"Extra": "Composting
|
| 187 |
},
|
| 188 |
"hazardous waste": {
|
| 189 |
-
"Recycling type": "Hazardous waste",
|
| 190 |
-
"Disposal": "Take batteries and
|
| 191 |
-
"Tips": "
|
| 192 |
-
"Extra": "Improper disposal
|
| 193 |
},
|
| 194 |
"electronic waste": {
|
| 195 |
"Recycling type": "Electronic waste recycling",
|
| 196 |
-
"Disposal": "
|
| 197 |
-
"Tips": "Remove batteries
|
| 198 |
-
"Extra": "
|
| 199 |
},
|
| 200 |
"textile": {
|
| 201 |
"Recycling type": "Textile recycling",
|
| 202 |
-
"Disposal": "Donate
|
| 203 |
-
"Tips": "Clean
|
| 204 |
-
"Extra": "
|
| 205 |
},
|
| 206 |
"general trash": {
|
| 207 |
"Recycling type": "General waste / landfill",
|
| 208 |
-
"Disposal": "Dispose of non-recyclable items in regular trash
|
| 209 |
-
"Tips": "
|
| 210 |
-
"Extra": "Reducing
|
| 211 |
}
|
| 212 |
}
|
| 213 |
|
| 214 |
waste_analyzation_v2 = {
|
| 215 |
"paper/cardboard": {
|
| 216 |
"Recycling type": "Paper recycling",
|
| 217 |
-
"Disposal": "Place dry paper and cardboard into the paper recycling container.",
|
| 218 |
-
"Tips": "
|
| 219 |
-
"Extra": "
|
| 220 |
},
|
| 221 |
"plastic": {
|
| 222 |
"Recycling type": "Plastic recycling",
|
| 223 |
-
"Disposal": "
|
| 224 |
-
"Tips": "
|
| 225 |
-
"Extra": "
|
| 226 |
},
|
| 227 |
"glass": {
|
| 228 |
"Recycling type": "Glass recycling",
|
| 229 |
-
"Disposal": "Recycle bottles and jars after
|
| 230 |
-
"Tips": "
|
| 231 |
-
"Extra": "Glass can be recycled
|
| 232 |
},
|
| 233 |
"metal": {
|
| 234 |
"Recycling type": "Metal recycling",
|
| 235 |
-
"Disposal": "Recycle
|
| 236 |
-
"Tips": "
|
| 237 |
-
"Extra": "
|
| 238 |
},
|
| 239 |
"organic waste": {
|
| 240 |
"Recycling type": "Compostable waste",
|
| 241 |
-
"Disposal": "
|
| 242 |
-
"Tips": "
|
| 243 |
-
"Extra": "
|
| 244 |
},
|
| 245 |
"hazardous waste": {
|
| 246 |
-
"Recycling type": "Hazardous materials
|
| 247 |
-
"Disposal": "
|
| 248 |
-
"Tips": "
|
| 249 |
-
"Extra": "
|
| 250 |
},
|
| 251 |
"electronic waste": {
|
| 252 |
"Recycling type": "E-waste recycling",
|
| 253 |
-
"Disposal": "Recycle electronics through
|
| 254 |
-
"Tips": "
|
| 255 |
-
"Extra": "
|
| 256 |
},
|
| 257 |
"textile": {
|
| 258 |
-
"Recycling type": "Clothing & textile
|
| 259 |
-
"Disposal": "
|
| 260 |
-
"Tips": "
|
| 261 |
-
"Extra": "
|
| 262 |
},
|
| 263 |
"general trash": {
|
| 264 |
"Recycling type": "Landfill waste",
|
| 265 |
-
"Disposal": "Throw away items that cannot be recycled.",
|
| 266 |
-
"Tips": "
|
| 267 |
-
"Extra": "Landfills should be a last resort."
|
| 268 |
}
|
| 269 |
}
|
| 270 |
|
| 271 |
waste_analyzation_v3 = {
|
| 272 |
"paper/cardboard": {
|
| 273 |
"Recycling type": "Paper & cardboard recycling",
|
| 274 |
-
"Disposal": "Recycle
|
| 275 |
-
"Tips": "
|
| 276 |
-
"Extra": "
|
| 277 |
},
|
| 278 |
"plastic": {
|
| 279 |
"Recycling type": "Plastic recycling",
|
| 280 |
-
"Disposal": "Recycle
|
| 281 |
-
"Tips": "
|
| 282 |
-
"Extra": "
|
| 283 |
},
|
| 284 |
"glass": {
|
| 285 |
"Recycling type": "Glass recycling",
|
| 286 |
-
"Disposal": "Recycle glass containers
|
| 287 |
-
"Tips": "
|
| 288 |
-
"Extra": "Glass recycling
|
| 289 |
},
|
| 290 |
"metal": {
|
| 291 |
"Recycling type": "Metal recycling",
|
| 292 |
-
"Disposal": "Recycle
|
| 293 |
-
"Tips": "
|
| 294 |
-
"Extra": "
|
| 295 |
},
|
| 296 |
"organic waste": {
|
| 297 |
"Recycling type": "Organic waste composting",
|
| 298 |
-
"Disposal": "
|
| 299 |
-
"Tips": "
|
| 300 |
-
"Extra": "
|
| 301 |
},
|
| 302 |
"hazardous waste": {
|
| 303 |
-
"Recycling type": "Hazardous waste
|
| 304 |
-
"Disposal": "Dispose of hazardous items at
|
| 305 |
-
"Tips": "
|
| 306 |
-
"Extra": "
|
| 307 |
},
|
| 308 |
"electronic waste": {
|
| 309 |
"Recycling type": "Electronic recycling",
|
| 310 |
-
"Disposal": "Recycle
|
| 311 |
-
"Tips": "
|
| 312 |
-
"Extra": "E-waste
|
| 313 |
},
|
| 314 |
"textile": {
|
| 315 |
"Recycling type": "Textile reuse & recycling",
|
| 316 |
-
"Disposal": "
|
| 317 |
-
"Tips": "
|
| 318 |
-
"Extra": "
|
| 319 |
},
|
| 320 |
"general trash": {
|
| 321 |
"Recycling type": "General disposal",
|
| 322 |
-
"Disposal": "Dispose of
|
| 323 |
-
"Tips": "
|
| 324 |
-
"Extra": "
|
| 325 |
}
|
| 326 |
}
|
| 327 |
|
| 328 |
analysis = [waste_analyzation_v3, waste_analyzation_v2, waste_analyzation_v1]
|
| 329 |
-
|
| 330 |
top_label = None
|
| 331 |
|
| 332 |
|
|
@@ -357,9 +356,7 @@ def analyze_pipeline():
|
|
| 357 |
|
| 358 |
|
| 359 |
# ------------------ GRADIO UI ------------------
|
| 360 |
-
# =========================
|
| 361 |
# CSS
|
| 362 |
-
# =========================
|
| 363 |
custom_css = """
|
| 364 |
|
| 365 |
|
|
@@ -411,9 +408,7 @@ textarea, .gr-textbox textarea, #explainbox textarea {
|
|
| 411 |
|
| 412 |
"""
|
| 413 |
|
| 414 |
-
# =========================
|
| 415 |
# GRADIO UI
|
| 416 |
-
# =========================
|
| 417 |
with gr.Blocks() as demo:
|
| 418 |
|
| 419 |
# TITLE
|
|
|
|
| 157 |
waste_analyzation_v1 = {
|
| 158 |
"paper/cardboard": {
|
| 159 |
"Recycling type": "Paper & Cardboard recycling",
|
| 160 |
+
"Disposal": "Flatten boxes and stack paper neatly before placing them in the paper recycling bin.",
|
| 161 |
+
"Tips": "If it’s wet, greasy, or food-stained, it’s better off in the trash or compost.",
|
| 162 |
+
"Extra": "Removing tape and plastic windows helps recycling facilities work more efficiently."
|
| 163 |
},
|
| 164 |
"plastic": {
|
| 165 |
"Recycling type": "Plastic recycling",
|
| 166 |
+
"Disposal": "Rinse plastic containers, let them dry, and place them in the plastic recycling bin.",
|
| 167 |
+
"Tips": "When in doubt, check the recycling number stamped on the item.",
|
| 168 |
+
"Extra": "Soft plastics like bags often need to be returned to collection points, not curbside bins."
|
| 169 |
},
|
| 170 |
"glass": {
|
| 171 |
"Recycling type": "Glass recycling",
|
| 172 |
+
"Disposal": "Rinse glass bottles or jars and place them gently into the glass container.",
|
| 173 |
+
"Tips": "Remove lids and caps, as they are usually recycled separately.",
|
| 174 |
+
"Extra": "Broken glass can be dangerous and may not be accepted in all programs."
|
| 175 |
},
|
| 176 |
"metal": {
|
| 177 |
"Recycling type": "Metal recycling",
|
| 178 |
+
"Disposal": "Empty and rinse metal cans before placing them in the metal recycling bin.",
|
| 179 |
+
"Tips": "Crushing cans saves space and reduces transport emissions.",
|
| 180 |
+
"Extra": "Never recycle pressurized or hazardous metal containers."
|
| 181 |
},
|
| 182 |
"organic waste": {
|
| 183 |
"Recycling type": "Organic / compost waste",
|
| 184 |
+
"Disposal": "Place food scraps and plant waste into a compost or organic waste bin.",
|
| 185 |
+
"Tips": "Cut large scraps into smaller pieces so they break down faster.",
|
| 186 |
+
"Extra": "Composting organic waste keeps valuable nutrients out of landfills."
|
| 187 |
},
|
| 188 |
"hazardous waste": {
|
| 189 |
+
"Recycling type": "Hazardous waste disposal",
|
| 190 |
+
"Disposal": "Take batteries and hazardous materials to official collection points.",
|
| 191 |
+
"Tips": "Store batteries in a dry container until you can dispose of them safely.",
|
| 192 |
+
"Extra": "Improper battery disposal is a common cause of recycling facility fires."
|
| 193 |
},
|
| 194 |
"electronic waste": {
|
| 195 |
"Recycling type": "Electronic waste recycling",
|
| 196 |
+
"Disposal": "Bring electronics to certified e-waste recycling centers.",
|
| 197 |
+
"Tips": "Remove batteries and personal data before disposal if possible.",
|
| 198 |
+
"Extra": "Electronics contain valuable metals that can be recovered and reused."
|
| 199 |
},
|
| 200 |
"textile": {
|
| 201 |
"Recycling type": "Textile recycling",
|
| 202 |
+
"Disposal": "Donate wearable clothing or place textiles in dedicated textile bins.",
|
| 203 |
+
"Tips": "Clean clothes before donating to improve reuse chances.",
|
| 204 |
+
"Extra": "Even damaged textiles can be recycled into industrial materials."
|
| 205 |
},
|
| 206 |
"general trash": {
|
| 207 |
"Recycling type": "General waste / landfill",
|
| 208 |
+
"Disposal": "Dispose of non-recyclable items in the regular trash bin.",
|
| 209 |
+
"Tips": "Try to separate recyclables carefully before throwing items away.",
|
| 210 |
+
"Extra": "Reducing trash helps lower landfill and incineration impact."
|
| 211 |
}
|
| 212 |
}
|
| 213 |
|
| 214 |
waste_analyzation_v2 = {
|
| 215 |
"paper/cardboard": {
|
| 216 |
"Recycling type": "Paper recycling",
|
| 217 |
+
"Disposal": "Place clean, dry paper and cardboard into the paper recycling container.",
|
| 218 |
+
"Tips": "Grease stains can ruin an entire batch of recycled paper.",
|
| 219 |
+
"Extra": "Paper fibers can only be recycled a limited number of times."
|
| 220 |
},
|
| 221 |
"plastic": {
|
| 222 |
"Recycling type": "Plastic recycling",
|
| 223 |
+
"Disposal": "Recycle plastic packaging that is accepted by your local program.",
|
| 224 |
+
"Tips": "Empty containers completely to avoid contamination.",
|
| 225 |
+
"Extra": "Not all plastics are recyclable, even if they look similar."
|
| 226 |
},
|
| 227 |
"glass": {
|
| 228 |
"Recycling type": "Glass recycling",
|
| 229 |
+
"Disposal": "Recycle glass bottles and jars after a quick rinse.",
|
| 230 |
+
"Tips": "Keep ceramics and drinking glasses out of glass recycling bins.",
|
| 231 |
+
"Extra": "Glass can be recycled repeatedly without losing quality."
|
| 232 |
},
|
| 233 |
"metal": {
|
| 234 |
"Recycling type": "Metal recycling",
|
| 235 |
+
"Disposal": "Recycle aluminum and steel cans once they are clean.",
|
| 236 |
+
"Tips": "Leaving food residue can attract pests during storage.",
|
| 237 |
+
"Extra": "Metal recycling saves a significant amount of energy."
|
| 238 |
},
|
| 239 |
"organic waste": {
|
| 240 |
"Recycling type": "Compostable waste",
|
| 241 |
+
"Disposal": "Put biodegradable food and garden waste into compost bins.",
|
| 242 |
+
"Tips": "Avoid adding liquids or oils unless your compost system allows it.",
|
| 243 |
+
"Extra": "Proper composting reduces methane emissions."
|
| 244 |
},
|
| 245 |
"hazardous waste": {
|
| 246 |
+
"Recycling type": "Hazardous materials handling",
|
| 247 |
+
"Disposal": "Dispose of batteries and chemicals through authorized programs.",
|
| 248 |
+
"Tips": "Tape battery terminals to reduce fire risk during transport.",
|
| 249 |
+
"Extra": "Hazardous waste should never be mixed with household trash."
|
| 250 |
},
|
| 251 |
"electronic waste": {
|
| 252 |
"Recycling type": "E-waste recycling",
|
| 253 |
+
"Disposal": "Recycle electronics through approved e-waste services.",
|
| 254 |
+
"Tips": "Check for manufacturer take-back programs.",
|
| 255 |
+
"Extra": "Many electronics contain toxic substances if mishandled."
|
| 256 |
},
|
| 257 |
"textile": {
|
| 258 |
+
"Recycling type": "Clothing & textile reuse",
|
| 259 |
+
"Disposal": "Reuse, donate, or recycle unwanted clothing responsibly.",
|
| 260 |
+
"Tips": "Repairing clothes can extend their life significantly.",
|
| 261 |
+
"Extra": "Textile waste is one of the fastest-growing waste streams."
|
| 262 |
},
|
| 263 |
"general trash": {
|
| 264 |
"Recycling type": "Landfill waste",
|
| 265 |
+
"Disposal": "Throw away items that cannot be reused or recycled.",
|
| 266 |
+
"Tips": "Reducing consumption is the best way to cut trash.",
|
| 267 |
+
"Extra": "Landfills should be a last resort whenever possible."
|
| 268 |
}
|
| 269 |
}
|
| 270 |
|
| 271 |
waste_analyzation_v3 = {
|
| 272 |
"paper/cardboard": {
|
| 273 |
"Recycling type": "Paper & cardboard recycling",
|
| 274 |
+
"Disposal": "Recycle paper-based items that are clean and dry.",
|
| 275 |
+
"Tips": "If you’re unsure, it’s safer to trash contaminated paper.",
|
| 276 |
+
"Extra": "Keeping recyclables clean improves overall recycling success."
|
| 277 |
},
|
| 278 |
"plastic": {
|
| 279 |
"Recycling type": "Plastic recycling",
|
| 280 |
+
"Disposal": "Recycle plastics according to local guidelines.",
|
| 281 |
+
"Tips": "A quick rinse is enough—no need to scrub perfectly.",
|
| 282 |
+
"Extra": "Reducing plastic use is often more effective than recycling."
|
| 283 |
},
|
| 284 |
"glass": {
|
| 285 |
"Recycling type": "Glass recycling",
|
| 286 |
+
"Disposal": "Recycle glass containers carefully to avoid breakage.",
|
| 287 |
+
"Tips": "Small broken pieces may be rejected by sorting machines.",
|
| 288 |
+
"Extra": "Glass recycling helps reduce raw material extraction."
|
| 289 |
},
|
| 290 |
"metal": {
|
| 291 |
"Recycling type": "Metal recycling",
|
| 292 |
+
"Disposal": "Recycle metal items that are empty and clean.",
|
| 293 |
+
"Tips": "Sharp edges should be handled with care.",
|
| 294 |
+
"Extra": "Recycling metal uses far less energy than producing new metal."
|
| 295 |
},
|
| 296 |
"organic waste": {
|
| 297 |
"Recycling type": "Organic waste composting",
|
| 298 |
+
"Disposal": "Compost food scraps and plant waste where available.",
|
| 299 |
+
"Tips": "Keep organic waste separate to avoid odors and pests.",
|
| 300 |
+
"Extra": "Compost can be used to enrich soil naturally."
|
| 301 |
},
|
| 302 |
"hazardous waste": {
|
| 303 |
+
"Recycling type": "Hazardous waste safety",
|
| 304 |
+
"Disposal": "Dispose of hazardous items only at proper facilities.",
|
| 305 |
+
"Tips": "Keep hazardous waste away from heat and moisture.",
|
| 306 |
+
"Extra": "Correct disposal protects both people and the environment."
|
| 307 |
},
|
| 308 |
"electronic waste": {
|
| 309 |
"Recycling type": "Electronic recycling",
|
| 310 |
+
"Disposal": "Recycle electronics instead of throwing them away.",
|
| 311 |
+
"Tips": "Many cities offer free e-waste collection events.",
|
| 312 |
+
"Extra": "E-waste recycling prevents toxic pollution."
|
| 313 |
},
|
| 314 |
"textile": {
|
| 315 |
"Recycling type": "Textile reuse & recycling",
|
| 316 |
+
"Disposal": "Choose reuse or recycling over disposal whenever possible.",
|
| 317 |
+
"Tips": "Even worn textiles can have a second life.",
|
| 318 |
+
"Extra": "Textile recycling reduces demand for new raw materials."
|
| 319 |
},
|
| 320 |
"general trash": {
|
| 321 |
"Recycling type": "General disposal",
|
| 322 |
+
"Disposal": "Dispose of remaining waste responsibly.",
|
| 323 |
+
"Tips": "Double-check recyclables before tossing items away.",
|
| 324 |
+
"Extra": "Small actions add up to meaningful waste reduction."
|
| 325 |
}
|
| 326 |
}
|
| 327 |
|
| 328 |
analysis = [waste_analyzation_v3, waste_analyzation_v2, waste_analyzation_v1]
|
|
|
|
| 329 |
top_label = None
|
| 330 |
|
| 331 |
|
|
|
|
| 356 |
|
| 357 |
|
| 358 |
# ------------------ GRADIO UI ------------------
|
|
|
|
| 359 |
# CSS
|
|
|
|
| 360 |
custom_css = """
|
| 361 |
|
| 362 |
|
|
|
|
| 408 |
|
| 409 |
"""
|
| 410 |
|
|
|
|
| 411 |
# GRADIO UI
|
|
|
|
| 412 |
with gr.Blocks() as demo:
|
| 413 |
|
| 414 |
# TITLE
|