DawnC commited on
Commit
ef32750
1 Parent(s): 08d39af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -293,18 +293,20 @@ async def predict(image):
293
 
294
  combined_confidence = detection_confidence * top1_prob
295
 
296
- if top1_prob >= 0.5:
297
  breed = topk_breeds[0]
298
  description = get_dog_description(breed)
299
  formatted_description = format_description(description, breed)
300
  explanations.append(f"Dog {i+1}: {formatted_description}")
301
- elif combined_confidence >= 0.2:
302
  dog_explanation = f"Dog {i+1}: Top 3 possible breeds:\n"
303
  dog_explanation += "\n".join([f"{j+1}. **{breed}** ({prob} confidence)" for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3]))])
304
  explanations.append(dog_explanation)
305
  buttons.extend([f"Dog {i+1}: More about {breed}" for breed in topk_breeds[:3]])
306
  else:
307
- explanations.append(f"Dog {i+1}: The image is unclear or the breed is not in the dataset. Please upload a clearer image.")
 
 
308
 
309
  final_explanation = "\n\n".join(explanations)
310
  if buttons:
 
293
 
294
  combined_confidence = detection_confidence * top1_prob
295
 
296
+ if top1_prob >= 0.45:
297
  breed = topk_breeds[0]
298
  description = get_dog_description(breed)
299
  formatted_description = format_description(description, breed)
300
  explanations.append(f"Dog {i+1}: {formatted_description}")
301
+ elif combined_confidence >= 0.15:
302
  dog_explanation = f"Dog {i+1}: Top 3 possible breeds:\n"
303
  dog_explanation += "\n".join([f"{j+1}. **{breed}** ({prob} confidence)" for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3]))])
304
  explanations.append(dog_explanation)
305
  buttons.extend([f"Dog {i+1}: More about {breed}" for breed in topk_breeds[:3]])
306
  else:
307
+ # explanations.append(f"Dog {i+1}: The image is unclear or the breed is not in the dataset. Please upload a clearer image.")
308
+ explanations.append("The image is unclear or the breed is not in the dataset. Please upload a clearer image.")
309
+
310
 
311
  final_explanation = "\n\n".join(explanations)
312
  if buttons: