smart-waste-ai / app.py
OGrohit's picture
Update app.py
53fc515 verified
import gradio as gr
from classifier import analyze_image
def analyze(image):
if image is None:
return "Please upload an image."
image.save("temp.jpg")
result = analyze_image("temp.jpg")
return f"""
๐Ÿง  **Detected Object:** {result['detected_object']}
๐Ÿ“Š **Object Confidence:** {result['object_confidence']}
โ™ป๏ธ **Waste Category:** {result['waste_category']}
๐Ÿ“Š **Waste Confidence:** {result['waste_confidence']}
๐Ÿ“ **Reason:**
{result['reason']}
๐Ÿšฎ **Disposal Method:**
{result['disposal']}
๐ŸŒ **Environmental Impact:**
{result['environmental_impact']}
"""
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("""
# โ™ป๏ธ Smart Waste AI
**Hybrid AI-powered Waste Segregation Advisor**
ResNet + CLIP (Zero-shot Vision Reasoning)
""")
image = gr.Image(type="pil", label="Upload Waste Image")
button = gr.Button("Analyze Waste", variant="primary")
output = gr.Markdown()
button.click(analyze, image, output)
gr.Markdown("""
---
๐Ÿ”— **GitHub:**https://github.com/rohitdecodes/smart-waste-ai
""")
demo.launch()