Spaces:
Build error
Build error
Commit ·
ad2a517
1
Parent(s): 596e564
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,8 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 7 |
def predict(image):
|
| 8 |
classifier = pipeline(task="image-classification")
|
| 9 |
preds = classifier(image)
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
return label
|
| 13 |
|
| 14 |
description = """
|
| 15 |
"""
|
|
@@ -18,10 +17,8 @@ gr.Interface(
|
|
| 18 |
fn=predict,
|
| 19 |
inputs=[
|
| 20 |
gr.components.Image(label="Image to classify", type="pil"),
|
| 21 |
-
# gr.inputs.Textbox(lines=1, label="Comma separated candidate labels", placeholder="Enter labels separated by ', '",)
|
| 22 |
],
|
| 23 |
outputs="label",
|
| 24 |
title="Comparateur d'image",
|
| 25 |
description=description
|
| 26 |
).launch()
|
| 27 |
-
|
|
|
|
| 7 |
def predict(image):
|
| 8 |
classifier = pipeline(task="image-classification")
|
| 9 |
preds = classifier(image)
|
| 10 |
+
preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
|
| 11 |
+
return preds
|
|
|
|
| 12 |
|
| 13 |
description = """
|
| 14 |
"""
|
|
|
|
| 17 |
fn=predict,
|
| 18 |
inputs=[
|
| 19 |
gr.components.Image(label="Image to classify", type="pil"),
|
|
|
|
| 20 |
],
|
| 21 |
outputs="label",
|
| 22 |
title="Comparateur d'image",
|
| 23 |
description=description
|
| 24 |
).launch()
|
|
|