def _shift_pic_bboxes(self, img, json_info):
...
for shape in shapes:
points = np.array(shape['points'])
x_min = min(x_min, points[:, 0].min())
y_min = min(y_min, points[:, 1].min())
x_max = max(x_max, points[:, 0].max())
y_max = max(y_max, points[:, 0].max()) # 这里需要修改 y_max = max(y_max, points[:, 1].max())
...
#目标的边缘在图片边缘的情况 是不能平移的
if (d_to_left < 1):
d_to_left = 1
if (d_to_right < 1):
d_to_right = 1
if (d_to_top < 1):
d_to_top = 1
if (d_to_bottom < 1):
d_to_bottom = 1
x = random.uniform(-(d_to_left - 1) / 3, (d_to_right - 1) / 3)
y = random.uniform(-(d_to_top - 1) / 3, (d_to_bottom - 1) / 3)