zjuJish commited on
Commit
8ba96c3
·
verified ·
1 Parent(s): 8643ce2

Upload layer_diff_dataset/change_mask.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. layer_diff_dataset/change_mask.py +23 -0
layer_diff_dataset/change_mask.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ from tqdm import tqdm
4
+ import cv2
5
+ import numpy as np
6
+
7
+ # 对mask进行膨胀
8
+
9
+ folder_path = '/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/train/gt'
10
+ folder_path_ = '/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/train/gt_dilate'
11
+ os.makedirs(folder_path_,exist_ok=True)
12
+ file_list = os.listdir(folder_path)
13
+ file_list = [i for i in file_list if i.endswith('.png')]
14
+ file_list.sort()
15
+
16
+ pbar = tqdm(enumerate(file_list),total=len(file_list))
17
+ for i, image_name in pbar:
18
+ gt = cv2.imread(os.path.join(folder_path,image_name),cv2.IMREAD_GRAYSCALE)
19
+ gt = cv2.resize(gt,(512,512))
20
+ kernel = np.ones((40, 40), np.uint8)
21
+ gt = cv2.dilate(gt,kernel,20)
22
+ gt = gt.clip(0, 255).round().astype('uint8')
23
+ cv2.imwrite(os.path.join(folder_path_,image_name),gt)