|
from transformers import pipeline |
|
|
|
|
|
pipe = pipeline("image-classification", model="DGurgurov/clip-vit-base-patch32-oxford-pets") |
|
|
|
|
|
def predict(image): |
|
|
|
results = pipe(image) |
|
return {f"Class {i}": result['label'] for i, result in enumerate(results)} |
|
|
|
|
|
import gradio as gr |
|
|
|
|
|
image = gr.components.Image() |
|
label = gr.components.Label(num_top_classes=5) |
|
|
|
interface = gr.Interface( |
|
fn=predict, |
|
inputs=image, |
|
outputs=label, |
|
title="CLIP Model - Oxford Pets", |
|
description="Upload an image and get the top 5 class predictions." |
|
) |
|
|
|
|
|
interface.launch(share=True) |
|
|