Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -79,6 +79,13 @@ def tag_image(pil_image: Image.Image, output_format: str) -> str:
|
|
79 |
else: # Detailed output
|
80 |
if not results_by_cat:
|
81 |
return "No tags predicted for this image."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
lines = []
|
83 |
lines.append("**Predicted Tags by Category:** \n") # (Markdown newline: two spaces + newline)
|
84 |
for cat, tag_list in results_by_cat.items():
|
|
|
79 |
else: # Detailed output
|
80 |
if not results_by_cat:
|
81 |
return "No tags predicted for this image."
|
82 |
+
|
83 |
+
# Ensure artist tag in detailed output even if below threshold
|
84 |
+
if 'artist' not in results_by_cat and all_artist_tags_probs:
|
85 |
+
best_artist_tag, best_artist_prob = max(all_artist_tags_probs, key=lambda item: item[1])
|
86 |
+
results_by_cat['artist'] = [(best_artist_tag, best_artist_prob)]
|
87 |
+
|
88 |
+
|
89 |
lines = []
|
90 |
lines.append("**Predicted Tags by Category:** \n") # (Markdown newline: two spaces + newline)
|
91 |
for cat, tag_list in results_by_cat.items():
|