Spaces:
Sleeping
Sleeping
Antoine245
commited on
Commit
·
22bc2c2
1
Parent(s):
51c985c
Update app.py
Browse files
app.py
CHANGED
@@ -9,21 +9,24 @@ def predict(image):
|
|
9 |
preds = classifier(image)
|
10 |
return {pred["label"]: round(float(pred["score"]), 4) for pred in preds}
|
11 |
|
12 |
-
def
|
13 |
-
|
14 |
-
|
15 |
|
16 |
description = """
|
17 |
"""
|
18 |
|
19 |
-
gr.Interface(
|
20 |
fn=predict,
|
21 |
inputs=[
|
22 |
gr.inputs.Image(label="Image to classify", type="pil"),
|
23 |
],
|
24 |
-
clear = gr.Button("Clear"),
|
25 |
outputs=gr.outputs.Label(),
|
26 |
title="Image Classifier",
|
27 |
-
description=description
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
9 |
preds = classifier(image)
|
10 |
return {pred["label"]: round(float(pred["score"]), 4) for pred in preds}
|
11 |
|
12 |
+
def clear_interface():
|
13 |
+
interface.inputs[0].clear()
|
14 |
+
interface.outputs[0].clear()
|
15 |
|
16 |
description = """
|
17 |
"""
|
18 |
|
19 |
+
interface = gr.Interface(
|
20 |
fn=predict,
|
21 |
inputs=[
|
22 |
gr.inputs.Image(label="Image to classify", type="pil"),
|
23 |
],
|
|
|
24 |
outputs=gr.outputs.Label(),
|
25 |
title="Image Classifier",
|
26 |
+
description=description,
|
27 |
+
buttons=[
|
28 |
+
gr.Button(label="Clear", callback=clear_interface)
|
29 |
+
]
|
30 |
+
)
|
31 |
+
|
32 |
+
interface.launch()
|