import gradio as gr # Waste classification function def classify_waste(item): item = item.lower() if any(word in item for word in ["paper", "plastic", "glass", "bottle", "metal", "tin", "cardboard"]): return "♻️ Recyclable - Please place in the recycling bin." elif any(word in item for word in ["fruit", "vegetable", "food", "banana", "apple", "peel", "veg"]): return "🌱 Compostable - Add it to compost or organic waste bin." elif any(word in item for word in ["syringe", "battery", "medicine", "chemical", "paint"]): return "⚠️ Harmful/Decomposable - Dispose at hazardous waste collection." else: return "🗑️ Trash - Dispose in general waste bin." # Gradio Interface iface = gr.Interface( fn=classify_waste, inputs=gr.Textbox(label="Enter item description"), outputs=gr.Textbox(label="Classification"), title="EcoSort ♻️", description="Type the name of a waste item (e.g., 'banana peel', 'plastic bottle', 'battery') and get eco-friendly disposal advice." ) # Run app if __name__ == "__main__": iface.launch()
verified