yjh0410 1 жил өмнө
parent
commit
2ed845c330

+ 2 - 2
dataset/data_augment/strong_augment.py

@@ -24,7 +24,7 @@ class MosaicAugment(object):
 
         mosaic_bboxes = []
         mosaic_labels = []
-        mosaic_img = np.zeros([self.img_size*2, self.img_size*2, image_list[0].shape[2]], dtype=np.uint8)
+        mosaic_img = np.ones([self.img_size*2, self.img_size*2, image_list[0].shape[2]], dtype=np.uint8) * 114
         for i in range(4):
             img_i, target_i = image_list[i], target_list[i]
             bboxes_i = target_i["boxes"]
@@ -195,7 +195,7 @@ class MixupAugment(object):
                 origin_image = cv2.resize(origin_image, resize_size, interpolation=interp)
 
             # pad new image
-            pad_origin_image = np.zeros([img_size, img_size, origin_image.shape[2]], dtype=np.uint8)
+            pad_origin_image = np.ones([img_size, img_size, origin_image.shape[2]], dtype=np.uint8) * 114
             pad_origin_image[:resize_size[1], :resize_size[0]] = origin_image
             origin_image = pad_origin_image.copy()
             del pad_origin_image

+ 2 - 2
dataset/data_augment/yolo_augment.py

@@ -56,9 +56,9 @@ def random_perspective(image,
     M = T @ S @ R @ P @ C  # order of operations (right to left) is IMPORTANT
     if (border[0] != 0) or (border[1] != 0) or (M != np.eye(3)).any():  # image changed
         if perspective:
-            image = cv2.warpPerspective(image, M, dsize=(width, height), borderValue=(0, 0, 0))
+            image = cv2.warpPerspective(image, M, dsize=(width, height), borderValue=(114, 114, 114))
         else:  # affine
-            image = cv2.warpAffine(image, M[:2], dsize=(width, height), borderValue=(0, 0, 0))
+            image = cv2.warpAffine(image, M[:2], dsize=(width, height), borderValue=(114, 114, 114))
 
     # Transform label coordinates
     n = len(targets)