Skip to content

Commit

Permalink
faster
Browse files Browse the repository at this point in the history
  • Loading branch information
WangLibo1995 committed Feb 18, 2023
1 parent d9edcf4 commit a5f35db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 2 additions & 4 deletions tools/potsdam_patch_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ def get_img_mask_padded(image, mask, patch_size, mode):
height_pad = 0 if rh == 0 else patch_size - rh

h, w = oh + height_pad, ow + width_pad
pad_img = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right',
border_mode=0, value=[0, 0, 0])(image=img)
pad_img = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right')(image=img)
if mode == 'train':
pad_img = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right')(image=img)

pad_mask = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right',
border_mode=0, value=[0, 0, 0])(image=mask)
pad_mask = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right')(image=mask)
img_pad, mask_pad = pad_img['image'], pad_mask['image']
img_pad = cv2.cvtColor(np.array(img_pad), cv2.COLOR_RGB2BGR)
mask_pad = cv2.cvtColor(np.array(mask_pad), cv2.COLOR_RGB2BGR)
Expand Down
7 changes: 3 additions & 4 deletions tools/vaihingen_patch_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ def get_img_mask_padded(image, mask, patch_size, mode):
height_pad = 0 if rh == 0 else patch_size - rh

h, w = oh + height_pad, ow + width_pad
pad_img = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right',
border_mode=0, value=[0, 0, 0])(image=img)
pad_img = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right')(image=img)
if mode == 'train':
pad_img = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right')(image=img)

pad_mask = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right',
border_mode=0, value=[0, 0, 0])(image=mask)
pad_mask = albu.PadIfNeeded(min_height=h, min_width=w, position='bottom_right')(image=mask)
img_pad, mask_pad = pad_img['image'], pad_mask['image']
img_pad = cv2.cvtColor(np.array(img_pad), cv2.COLOR_RGB2BGR)
mask_pad = cv2.cvtColor(np.array(mask_pad), cv2.COLOR_RGB2BGR)
Expand Down Expand Up @@ -111,6 +109,7 @@ def image_augment(image, mask, patch_size, mode='train', val_scale=1.0):
mask_list = []
image_width, image_height = image.size[1], image.size[0]
mask_width, mask_height = mask.size[1], mask.size[0]

assert image_height == mask_height and image_width == mask_width
if mode == 'train':
# resize_0 = Resize(size=(int(image_width * 0.25), int(image_height * 0.25)))
Expand Down

0 comments on commit a5f35db

Please sign in to comment.