Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -357,10 +357,10 @@ async def process_multiple_dogs_result(dogs, image):
|
|
357 |
if top1_prob >= 0.5:
|
358 |
breed = topk_breeds[0]
|
359 |
description = get_dog_description(breed)
|
360 |
-
explanations.append(f"Dog {i}: **{breed}
|
361 |
-
|
362 |
explanation = f"""
|
363 |
-
Dog {i}:
|
364 |
1. **{topk_breeds[0]}** ({topk_probs_percent[0]})
|
365 |
2. **{topk_breeds[1]}** ({topk_probs_percent[1]})
|
366 |
3. **{topk_breeds[2]}** ({topk_probs_percent[2]})
|
@@ -368,13 +368,15 @@ Dog {i}: Detected with moderate confidence. Here are the top 3 possible breeds:
|
|
368 |
explanations.append(explanation)
|
369 |
for breed in topk_breeds:
|
370 |
buttons.append(f"More about Dog {i}: {breed}")
|
|
|
|
|
371 |
|
372 |
final_explanation = "\n\n---\n\n".join(explanations)
|
373 |
|
374 |
-
if
|
375 |
-
return
|
376 |
-
|
377 |
-
|
378 |
|
379 |
async def process_single_dog_result(top1_prob, topk_breeds, topk_probs_percent, image, box):
|
380 |
annotated_image = image.copy()
|
|
|
357 |
if top1_prob >= 0.5:
|
358 |
breed = topk_breeds[0]
|
359 |
description = get_dog_description(breed)
|
360 |
+
explanations.append(f"Dog {i}: **{breed}**\n\n{format_description(description, breed, is_multi_dog=True, dog_number=i)}")
|
361 |
+
elif top1_prob >= 0.2:
|
362 |
explanation = f"""
|
363 |
+
Dog {i}: The model couldn't confidently identify the breed. Here are the top 3 possible breeds:
|
364 |
1. **{topk_breeds[0]}** ({topk_probs_percent[0]})
|
365 |
2. **{topk_breeds[1]}** ({topk_probs_percent[1]})
|
366 |
3. **{topk_breeds[2]}** ({topk_probs_percent[2]})
|
|
|
368 |
explanations.append(explanation)
|
369 |
for breed in topk_breeds:
|
370 |
buttons.append(f"More about Dog {i}: {breed}")
|
371 |
+
else:
|
372 |
+
explanations.append(f"Dog {i}: The image is unclear or the breed is not in the dataset. Please upload a clearer image of a dog.")
|
373 |
|
374 |
final_explanation = "\n\n---\n\n".join(explanations)
|
375 |
|
376 |
+
if not explanations:
|
377 |
+
return "No dogs were confidently detected in the image. Please upload a clearer image of a dog.", annotated_image, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
378 |
+
|
379 |
+
return final_explanation, annotated_image, gr.update(visible=bool(buttons), choices=buttons), gr.update(visible=False), gr.update(visible=False)
|
380 |
|
381 |
async def process_single_dog_result(top1_prob, topk_breeds, topk_probs_percent, image, box):
|
382 |
annotated_image = image.copy()
|