Spaces:
Sleeping
Sleeping
Commit
·
dfec65b
1
Parent(s):
cffe60c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
6 |
+
|
7 |
+
def predict(image, labels):
|
8 |
+
classifier = pipeline(task="image-classification")
|
9 |
+
inputs = classifier(image)
|
10 |
+
preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
|
11 |
+
return preds
|
12 |
+
|
13 |
+
description = """
|
14 |
+
"""
|
15 |
+
|
16 |
+
gr.Interface(
|
17 |
+
fn=predict,
|
18 |
+
inputs=[
|
19 |
+
gr.inputs.Image(label="Image to classify", type="pil"),
|
20 |
+
# gr.inputs.Textbox(lines=1, label="Comma separated candidate labels", placeholder="Enter labels separated by ', '",)
|
21 |
+
],
|
22 |
+
theme="grass",
|
23 |
+
outputs="label",
|
24 |
+
title="Comparateur d'image",
|
25 |
+
description=description
|
26 |
+
).launch()
|