Spaces:
Runtime error
Runtime error
sshi
commited on
Commit
·
6d9e76a
1
Parent(s):
27158a8
App bug fix.
Browse files
app.py
CHANGED
|
@@ -115,17 +115,22 @@ def plot_results(pil_img, prob, boxes):
|
|
| 115 |
|
| 116 |
for p, (xmin, ymin, xmax, ymax) in zip(prob, boxes.tolist()):
|
| 117 |
cl = p.argmax()
|
| 118 |
-
c = colors[cl]
|
| 119 |
c1, c2 = (int(xmin), int(ymin)), (int(xmax), int(ymax))
|
| 120 |
|
| 121 |
-
cv2.rectangle(img, c1, c2,
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
# ax.text(xmin, ymin, text, fontsize=10,
|
| 127 |
# bbox=dict(facecolor=c, alpha=0.5))
|
| 128 |
-
return Image.fromarray(img
|
| 129 |
# return fig
|
| 130 |
|
| 131 |
|
|
|
|
| 115 |
|
| 116 |
for p, (xmin, ymin, xmax, ymax) in zip(prob, boxes.tolist()):
|
| 117 |
cl = p.argmax()
|
| 118 |
+
c = int(colors[cl])
|
| 119 |
c1, c2 = (int(xmin), int(ymin)), (int(xmax), int(ymax))
|
| 120 |
|
| 121 |
+
cv2.rectangle(img, c1, c2, c, thickness=2, lineType=cv2.LINE_AA)
|
| 122 |
+
|
| 123 |
+
cv2.putText(
|
| 124 |
+
img,
|
| 125 |
+
f'{id2label[cl.item()]}: {p[cl]:0.2f}',
|
| 126 |
+
[xmin + 5, ymin + 5],
|
| 127 |
+
cv2.FONT_HERSHEY_SIMPLEX,
|
| 128 |
+
0.7,
|
| 129 |
+
c,
|
| 130 |
+
2)
|
| 131 |
# ax.text(xmin, ymin, text, fontsize=10,
|
| 132 |
# bbox=dict(facecolor=c, alpha=0.5))
|
| 133 |
+
return Image.fromarray(img)
|
| 134 |
# return fig
|
| 135 |
|
| 136 |
|