Update utils.py (#273)

speed up code
This commit is contained in:
liubo0902 2023-02-09 19:48:38 +08:00 committed by GitHub
parent 8d27ce1ed6
commit 265d4cc6e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,14 +148,14 @@ def get_image_boxes(bounding_boxes, img, size=24):
bounding_boxes, width, height
)
img_boxes = np.zeros((num_boxes, 3, size, size), "float32")
img_array = np.asarray(img, "uint8")
for i in range(num_boxes):
img_box = np.zeros((h[i], w[i], 3), "uint8")
img_array = np.asarray(img, "uint8")
img_box[dy[i] : (edy[i] + 1), dx[i] : (edx[i] + 1), :] = img_array[
y[i] : (ey[i] + 1), x[i] : (ex[i] + 1), :
]
].copy()
# resize
img_box = Image.fromarray(img_box)