File size: 722 Bytes
dfec65b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import torch
import gradio as gr
from transformers import pipeline

device = "cuda" if torch.cuda.is_available() else "cpu"

def predict(image, labels):
    classifier = pipeline(task="image-classification")
    inputs = classifier(image)
    preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
    return preds

description = """
"""

gr.Interface(
    fn=predict,
    inputs=[
        gr.inputs.Image(label="Image to classify", type="pil"),
        # gr.inputs.Textbox(lines=1, label="Comma separated candidate labels", placeholder="Enter labels separated by ', '",)
    ],
    theme="grass",
    outputs="label",
    title="Comparateur d'image",
    description=description
).launch()