Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -52,8 +52,12 @@ def predict_tags(image_url, threshold=0.5):
|
|
52 |
def gradio_predict(url, threshold):
|
53 |
tags, error = predict_tags(url, threshold)
|
54 |
if error:
|
55 |
-
return error
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
|
58 |
demo = gr.Interface(
|
59 |
fn=gradio_predict,
|
|
|
52 |
def gradio_predict(url, threshold):
|
53 |
tags, error = predict_tags(url, threshold)
|
54 |
if error:
|
55 |
+
return {"error": error}
|
56 |
+
if not tags:
|
57 |
+
return {"error": "No tags above threshold."}
|
58 |
+
|
59 |
+
top_tag, top_score = tags[0]
|
60 |
+
return {"tag_name": top_tag, "tag_score": round(top_score, 4)}
|
61 |
|
62 |
demo = gr.Interface(
|
63 |
fn=gradio_predict,
|