|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
pipe = pipeline("image-classification", model="heisenberg3376/vit-base-food-items-v1") |
|
|
|
|
|
def classify_image(input_image): |
|
|
|
results = pipe(input_image) |
|
|
|
|
|
confidences = {result['label']: float(result['score']) for result in results} |
|
|
|
|
|
return confidences |
|
|
|
|
|
iface = gr.Interface( |
|
fn=classify_image, |
|
inputs=gr.Image(type="pil", label="Upload an image"), |
|
outputs=gr.Label(num_top_classes=5), |
|
title="Image Classification", |
|
description="Classify food items in images using heisenberg3376/vit-base-food-items-v1" |
|
) |
|
|
|
|
|
iface.launch() |
|
|