haxerwddle commited on
Commit
92ae382
·
1 Parent(s): a746dfb

Analysis change

Browse files
Files changed (1) hide show
  1. app.py +85 -90
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 place clean paper or cardboard into the paper recycling bin.",
161
- "Tips": "Remove tape, staples, and plastic covers before recycling.",
162
- "Extra": "Wet or food-stained paper should not be recycled."
163
  },
164
  "plastic": {
165
  "Recycling type": "Plastic recycling",
166
- "Disposal": "Rinse plastic containers and place accepted plastics into the recycling bin.",
167
- "Tips": "Check the recycling code on the plastic item.",
168
- "Extra": "Soft plastics may require special drop-off locations."
169
  },
170
  "glass": {
171
  "Recycling type": "Glass recycling",
172
- "Disposal": "Rinse glass bottles and jars and place them in the glass recycling container.",
173
- "Tips": "Remove lids and caps before disposal.",
174
- "Extra": "Broken glass may not be accepted in curbside programs."
175
  },
176
  "metal": {
177
  "Recycling type": "Metal recycling",
178
- "Disposal": "Clean aluminum cans and metal containers before recycling.",
179
- "Tips": "Crushing cans helps save space.",
180
- "Extra": "Do not include batteries or electronics."
181
  },
182
  "organic waste": {
183
  "Recycling type": "Organic / compost waste",
184
- "Disposal": "Place food scraps and organic matter into compost or organic waste bins.",
185
- "Tips": "Avoid mixing organic waste with plastics.",
186
- "Extra": "Composting reduces landfill emissions."
187
  },
188
  "hazardous waste": {
189
- "Recycling type": "Hazardous waste",
190
- "Disposal": "Take batteries and chemicals to designated hazardous waste facilities.",
191
- "Tips": "Never place hazardous items in regular trash.",
192
- "Extra": "Improper disposal can cause fires or pollution."
193
  },
194
  "electronic waste": {
195
  "Recycling type": "Electronic waste recycling",
196
- "Disposal": "Drop off electronic devices at certified e-waste centers.",
197
- "Tips": "Remove batteries if possible before disposal.",
198
- "Extra": "Many electronics contain recyclable metals."
199
  },
200
  "textile": {
201
  "Recycling type": "Textile recycling",
202
- "Disposal": "Donate usable clothing or place textiles in textile recycling bins.",
203
- "Tips": "Clean items before donation or recycling.",
204
- "Extra": "Damaged textiles may be repurposed into insulation."
205
  },
206
  "general trash": {
207
  "Recycling type": "General waste / landfill",
208
- "Disposal": "Dispose of non-recyclable items in regular trash bins.",
209
- "Tips": "Avoid mixing recyclables with trash.",
210
- "Extra": "Reducing waste helps the environment."
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": "Keep paper clean and dry.",
219
- "Extra": "Pizza boxes with grease stains should go to trash or compost."
220
  },
221
  "plastic": {
222
  "Recycling type": "Plastic recycling",
223
- "Disposal": "Sort plastics by type and recycle accepted items.",
224
- "Tips": "Remove food residue before recycling.",
225
- "Extra": "Some plastics cannot be recycled curbside."
226
  },
227
  "glass": {
228
  "Recycling type": "Glass recycling",
229
- "Disposal": "Recycle bottles and jars after rinsing.",
230
- "Tips": "Avoid mixing ceramics with glass.",
231
- "Extra": "Glass can be recycled indefinitely."
232
  },
233
  "metal": {
234
  "Recycling type": "Metal recycling",
235
- "Disposal": "Recycle metal cans and containers once cleaned.",
236
- "Tips": "Steel and aluminum are both recyclable.",
237
- "Extra": "Large metal items may need special pickup."
238
  },
239
  "organic waste": {
240
  "Recycling type": "Compostable waste",
241
- "Disposal": "Dispose of organic materials in compost bins.",
242
- "Tips": "Cut large food scraps into smaller pieces.",
243
- "Extra": "Composting improves soil quality."
244
  },
245
  "hazardous waste": {
246
- "Recycling type": "Hazardous materials disposal",
247
- "Disposal": "Bring hazardous items to approved collection points.",
248
- "Tips": "Store batteries safely before disposal.",
249
- "Extra": "Never burn or crush batteries."
250
  },
251
  "electronic waste": {
252
  "Recycling type": "E-waste recycling",
253
- "Disposal": "Recycle electronics through authorized recyclers.",
254
- "Tips": "Back up and wipe data before disposal.",
255
- "Extra": "E-waste contains valuable recoverable materials."
256
  },
257
  "textile": {
258
- "Recycling type": "Clothing & textile recycling",
259
- "Disposal": "Donate or recycle unwanted clothes responsibly.",
260
- "Tips": "Separate wearable and damaged items.",
261
- "Extra": "Textiles can be reused or downcycled."
262
  },
263
  "general trash": {
264
  "Recycling type": "Landfill waste",
265
- "Disposal": "Throw away items that cannot be recycled.",
266
- "Tips": "Reduce waste whenever possible.",
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 clean paper-based materials.",
275
- "Tips": "Avoid recycling paper mixed with plastic.",
276
- "Extra": "Paper fibers can only be recycled a few times."
277
  },
278
  "plastic": {
279
  "Recycling type": "Plastic recycling",
280
- "Disposal": "Recycle only plastics accepted locally.",
281
- "Tips": "Flatten bottles to save space.",
282
- "Extra": "Plastic recycling rules vary by region."
283
  },
284
  "glass": {
285
  "Recycling type": "Glass recycling",
286
- "Disposal": "Recycle glass containers after rinsing.",
287
- "Tips": "Sort by color if required.",
288
- "Extra": "Glass recycling saves raw materials."
289
  },
290
  "metal": {
291
  "Recycling type": "Metal recycling",
292
- "Disposal": "Recycle clean metal containers.",
293
- "Tips": "Do not include pressurized containers.",
294
- "Extra": "Metal recycling saves energy."
295
  },
296
  "organic waste": {
297
  "Recycling type": "Organic waste composting",
298
- "Disposal": "Place biodegradable waste into compost bins.",
299
- "Tips": "Avoid adding oils or meat if not accepted.",
300
- "Extra": "Organic waste can be turned into fertilizer."
301
  },
302
  "hazardous waste": {
303
- "Recycling type": "Hazardous waste handling",
304
- "Disposal": "Dispose of hazardous items at certified facilities.",
305
- "Tips": "Handle with care and keep away from heat.",
306
- "Extra": "Improper disposal poses health risks."
307
  },
308
  "electronic waste": {
309
  "Recycling type": "Electronic recycling",
310
- "Disposal": "Recycle electronic devices properly.",
311
- "Tips": "Check local e-waste programs.",
312
- "Extra": "E-waste contains toxic substances."
313
  },
314
  "textile": {
315
  "Recycling type": "Textile reuse & recycling",
316
- "Disposal": "Donate or recycle textiles responsibly.",
317
- "Tips": "Reuse clothing whenever possible.",
318
- "Extra": "Fast fashion contributes to waste."
319
  },
320
  "general trash": {
321
  "Recycling type": "General disposal",
322
- "Disposal": "Dispose of non-recyclables in trash.",
323
- "Tips": "Sort waste correctly before disposal.",
324
- "Extra": "Reducing waste helps the planet."
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