提交 096dde95 编写于 作者: W wangxinxin08

add comment to trigger pre-commit

上级 d576a61a
...@@ -61,10 +61,7 @@ def is_overlap(object_bbox, sample_bbox): ...@@ -61,10 +61,7 @@ def is_overlap(object_bbox, sample_bbox):
return True return True
def filter_and_process(sample_bbox, def filter_and_process(sample_bbox, bboxes, labels, scores=None,
bboxes,
labels,
scores=None,
keypoints=None): keypoints=None):
new_bboxes = [] new_bboxes = []
new_labels = [] new_labels = []
...@@ -95,8 +92,8 @@ def filter_and_process(sample_bbox, ...@@ -95,8 +92,8 @@ def filter_and_process(sample_bbox,
for j in range(len(sample_keypoint)): for j in range(len(sample_keypoint)):
kp_len = sample_height if j % 2 else sample_width kp_len = sample_height if j % 2 else sample_width
sample_coord = sample_bbox[1] if j % 2 else sample_bbox[0] sample_coord = sample_bbox[1] if j % 2 else sample_bbox[0]
sample_keypoint[j] = (sample_keypoint[j] - sample_keypoint[j] = (
sample_coord) / kp_len sample_keypoint[j] - sample_coord) / kp_len
sample_keypoint[j] = max(min(sample_keypoint[j], 1.0), 0.0) sample_keypoint[j] = max(min(sample_keypoint[j], 1.0), 0.0)
new_keypoints.append(sample_keypoint) new_keypoints.append(sample_keypoint)
new_kp_ignore.append(keypoints[1][i]) new_kp_ignore.append(keypoints[1][i])
...@@ -264,12 +261,12 @@ def jaccard_overlap(sample_bbox, object_bbox): ...@@ -264,12 +261,12 @@ def jaccard_overlap(sample_bbox, object_bbox):
intersect_ymin = max(sample_bbox[1], object_bbox[1]) intersect_ymin = max(sample_bbox[1], object_bbox[1])
intersect_xmax = min(sample_bbox[2], object_bbox[2]) intersect_xmax = min(sample_bbox[2], object_bbox[2])
intersect_ymax = min(sample_bbox[3], object_bbox[3]) intersect_ymax = min(sample_bbox[3], object_bbox[3])
intersect_size = (intersect_xmax - intersect_xmin) * (intersect_ymax - intersect_size = (intersect_xmax - intersect_xmin) * (
intersect_ymin) intersect_ymax - intersect_ymin)
sample_bbox_size = bbox_area(sample_bbox) sample_bbox_size = bbox_area(sample_bbox)
object_bbox_size = bbox_area(object_bbox) object_bbox_size = bbox_area(object_bbox)
overlap = intersect_size / (sample_bbox_size + object_bbox_size - overlap = intersect_size / (
intersect_size) sample_bbox_size + object_bbox_size - intersect_size)
return overlap return overlap
...@@ -279,10 +276,8 @@ def intersect_bbox(bbox1, bbox2): ...@@ -279,10 +276,8 @@ def intersect_bbox(bbox1, bbox2):
intersection_box = [0.0, 0.0, 0.0, 0.0] intersection_box = [0.0, 0.0, 0.0, 0.0]
else: else:
intersection_box = [ intersection_box = [
max(bbox1[0], bbox2[0]), max(bbox1[0], bbox2[0]), max(bbox1[1], bbox2[1]),
max(bbox1[1], bbox2[1]), min(bbox1[2], bbox2[2]), min(bbox1[3], bbox2[3])
min(bbox1[2], bbox2[2]),
min(bbox1[3], bbox2[3])
] ]
return intersection_box return intersection_box
...@@ -406,8 +401,8 @@ def crop_image_sampling(img, sample_bbox, image_width, image_height, ...@@ -406,8 +401,8 @@ def crop_image_sampling(img, sample_bbox, image_width, image_height,
sample_img[roi_y1: roi_y2, roi_x1: roi_x2] = \ sample_img[roi_y1: roi_y2, roi_x1: roi_x2] = \
img[cross_y1: cross_y2, cross_x1: cross_x2] img[cross_y1: cross_y2, cross_x1: cross_x2]
sample_img = cv2.resize(sample_img, (target_size, target_size), sample_img = cv2.resize(
interpolation=cv2.INTER_AREA) sample_img, (target_size, target_size), interpolation=cv2.INTER_AREA)
return sample_img return sample_img
...@@ -454,8 +449,8 @@ def draw_gaussian(heatmap, center, radius, k=1, delte=6): ...@@ -454,8 +449,8 @@ def draw_gaussian(heatmap, center, radius, k=1, delte=6):
top, bottom = min(y, radius), min(height - y, radius + 1) top, bottom = min(y, radius), min(height - y, radius + 1)
masked_heatmap = heatmap[y - top:y + bottom, x - left:x + right] masked_heatmap = heatmap[y - top:y + bottom, x - left:x + right]
masked_gaussian = gaussian[radius - top:radius + bottom, masked_gaussian = gaussian[radius - top:radius + bottom, radius - left:
radius - left:radius + right] radius + right]
np.maximum(masked_heatmap, masked_gaussian * k, out=masked_heatmap) np.maximum(masked_heatmap, masked_gaussian * k, out=masked_heatmap)
...@@ -463,8 +458,8 @@ def gaussian2D(shape, sigma_x=1, sigma_y=1): ...@@ -463,8 +458,8 @@ def gaussian2D(shape, sigma_x=1, sigma_y=1):
m, n = [(ss - 1.) / 2. for ss in shape] m, n = [(ss - 1.) / 2. for ss in shape]
y, x = np.ogrid[-m:m + 1, -n:n + 1] y, x = np.ogrid[-m:m + 1, -n:n + 1]
h = np.exp(-(x * x / (2 * sigma_x * sigma_x) + y * y / h = np.exp(-(x * x / (2 * sigma_x * sigma_x) + y * y / (2 * sigma_y *
(2 * sigma_y * sigma_y))) sigma_y)))
h[h < np.finfo(h.dtype).eps * h.max()] = 0 h[h < np.finfo(h.dtype).eps * h.max()] = 0
return h return h
...@@ -482,6 +477,7 @@ def transform_bbox(bbox, ...@@ -482,6 +477,7 @@ def transform_bbox(bbox,
n = len(bbox) n = len(bbox)
xy = np.ones((n * 4, 3), dtype=np.float32) xy = np.ones((n * 4, 3), dtype=np.float32)
xy[:, :2] = bbox[:, [0, 1, 2, 3, 0, 3, 2, 1]].reshape(n * 4, 2) xy[:, :2] = bbox[:, [0, 1, 2, 3, 0, 3, 2, 1]].reshape(n * 4, 2)
# xy = xy @ M.T
xy = np.matmul(xy, M.T) xy = np.matmul(xy, M.T)
if perspective: if perspective:
xy = (xy[:, :2] / xy[:, 2:3]).reshape(n, 8) xy = (xy[:, :2] / xy[:, 2:3]).reshape(n, 8)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册