Spaces:
Sleeping
Sleeping
import torch | |
import gradio as gr | |
from transformers import pipeline | |
def predict(image): | |
classifier = pipeline(task="image-classification") | |
preds = classifier(image) | |
return {pred["label"]: round(float(pred["score"]), 4) for pred in preds} | |
description = """ | |
""" | |
interface = gr.Interface( | |
fn=predict, | |
inputs=[ | |
gr.inputs.Image(label="Image to classify", type="pil"), | |
], | |
outputs=gr.outputs.Label(), | |
examples=[ | |
["rafale.jpg",], | |
], | |
title="Image Classifier", | |
description=description | |
) | |
interface.launch() | |