|
import gradio as gr |
|
from transformers import pipeline |
|
from PIL import Image |
|
|
|
|
|
agent = pipeline("image-classification", model="your-username/your-model-name") |
|
|
|
def analyze_image(image): |
|
results = agent(image) |
|
|
|
return {r["label"]: r["score"] for r in results} |
|
|
|
|
|
demo = gr.Interface( |
|
fn=analyze_image, |
|
inputs=gr.Image(type="pil"), |
|
outputs=gr.Label(num_top_classes=3), |
|
examples=["example1.jpg", "example2.jpg"], |
|
title="π‘οΈ AI Vision Agent: Security Compliance Assistant", |
|
description="Upload an image to detect clean-desk violations, unattended devices, and more!", |
|
) |
|
|
|
demo.launch() |