Spaces:
Runtime error
Runtime error
add a button to apply tags
Browse files
app.py
CHANGED
|
@@ -54,6 +54,17 @@ if st.button('apply tag'):
|
|
| 54 |
image,
|
| 55 |
candidate_labels=['eggs', 'apple', 'pear']
|
| 56 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
#i = 0 # Retrieve predictions for the first image for the corresponding text queries
|
| 58 |
#text = tags[i]
|
| 59 |
#boxes, scores, labels = results[i]["boxes"], results[i]["scores"], results[i]["labels"]
|
|
|
|
| 54 |
image,
|
| 55 |
candidate_labels=['eggs', 'apple', 'pear']
|
| 56 |
)
|
| 57 |
+
|
| 58 |
+
draw = ImageDraw.Draw(image)
|
| 59 |
+
|
| 60 |
+
for prediction in predictions:
|
| 61 |
+
box = prediction["box"]
|
| 62 |
+
label = prediction["label"]
|
| 63 |
+
score = prediction["score"]
|
| 64 |
+
|
| 65 |
+
xmin, ymin, xmax, ymax = box.values()
|
| 66 |
+
draw.rectangle((xmin, ymin, xmax, ymax), outline="red", width=1)
|
| 67 |
+
draw.text((xmin, ymin), f"{label}: {round(score,2)}", fill="white")
|
| 68 |
#i = 0 # Retrieve predictions for the first image for the corresponding text queries
|
| 69 |
#text = tags[i]
|
| 70 |
#boxes, scores, labels = results[i]["boxes"], results[i]["scores"], results[i]["labels"]
|