Skip to content

Commit d107c81

Browse files
committed
Fix bugs for apple silicon mac
i referred this issue hunglc007/tensorflow-yolov4-tflite#368
1 parent 36a2025 commit d107c81

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

conda-gpu-apple-silicon-mac.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: yolov4-gpu
22

33
channels:
44
- apple
5+
- conda-forge
56
dependencies:
67
- tensorflow-deps
78
- matplotlib
@@ -13,6 +14,7 @@ dependencies:
1314
- pillow
1415
- waitress
1516
- paste
17+
- easydic
1618
- pip:
1719
- tensorflow-macos
1820
- tensorflow-metal

core/utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ def draw_bbox(image, bboxes, classes=read_class_names(cfg.YOLO.CLASSES), allowed
155155
else:
156156
bbox_color = colors[class_ind]
157157
bbox_thick = int(0.6 * (image_h + image_w) / 600)
158-
c1, c2 = (coor[1], coor[0]), (coor[3], coor[2])
158+
c1, c2 = (int(coor[1]), int(coor[0])), (int(coor[3]), int(coor[2]))
159159
cv2.rectangle(image, c1, c2, bbox_color, bbox_thick)
160160

161161
if show_label:
162162
bbox_mess = '%s: %.2f' % (classes[class_ind], score)
163163
t_size = cv2.getTextSize(bbox_mess, 0, fontScale, thickness=bbox_thick // 2)[0]
164164
c3 = (c1[0] + t_size[0], c1[1] - t_size[1] - 3)
165-
cv2.rectangle(image, c1, (np.float32(c3[0]), np.float32(c3[1])), bbox_color, -1) #filled
165+
cv2.rectangle(image, c1, (int(np.float32(c3[0])), int(np.float32(c3[1]))), bbox_color, -1) #filled
166166

167-
cv2.putText(image, bbox_mess, (c1[0], np.float32(c1[1] - 2)), cv2.FONT_HERSHEY_SIMPLEX,
167+
cv2.putText(image, bbox_mess, (c1[0], int(np.float32(c1[1] - 2))), cv2.FONT_HERSHEY_SIMPLEX,
168168
fontScale, (0, 0, 0), bbox_thick // 2, lineType=cv2.LINE_AA)
169169
return image
170170

0 commit comments

Comments
 (0)