Spaces:
Runtime error
Runtime error
Commit
•
ffa5b50
1
Parent(s):
0555ed4
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,9 @@ def classify_image(image, candidate_labels):
|
|
37 |
for score, candidate_label in sorted(zip(probs, candidate_labels), key=lambda x: -x[0])
|
38 |
]
|
39 |
|
|
|
|
|
|
|
40 |
# Decision-making logic
|
41 |
top_label = results[0]["label"]
|
42 |
second_label = results[1]["label"]
|
@@ -58,7 +61,7 @@ def classify_image(image, candidate_labels):
|
|
58 |
else:
|
59 |
result = False
|
60 |
|
61 |
-
return result, top_label,
|
62 |
|
63 |
iface = gr.Interface(
|
64 |
fn=classify_image,
|
@@ -69,7 +72,7 @@ iface = gr.Interface(
|
|
69 |
outputs=[
|
70 |
gr.Label(label="Result"),
|
71 |
gr.Textbox(label="Top Label"),
|
72 |
-
gr.Dataframe(label="Details"),
|
73 |
gr.Textbox(label="Messages")
|
74 |
],
|
75 |
title="General Action Classifier",
|
|
|
37 |
for score, candidate_label in sorted(zip(probs, candidate_labels), key=lambda x: -x[0])
|
38 |
]
|
39 |
|
40 |
+
# Convert results to list of lists for Dataframe
|
41 |
+
results_for_df = [[res['label'], res['score']] for res in results]
|
42 |
+
|
43 |
# Decision-making logic
|
44 |
top_label = results[0]["label"]
|
45 |
second_label = results[1]["label"]
|
|
|
61 |
else:
|
62 |
result = False
|
63 |
|
64 |
+
return result, top_label, results_for_df, messages
|
65 |
|
66 |
iface = gr.Interface(
|
67 |
fn=classify_image,
|
|
|
72 |
outputs=[
|
73 |
gr.Label(label="Result"),
|
74 |
gr.Textbox(label="Top Label"),
|
75 |
+
gr.Dataframe(headers=["Label", "Score"], label="Details"),
|
76 |
gr.Textbox(label="Messages")
|
77 |
],
|
78 |
title="General Action Classifier",
|