Upload layer_diff_dataset/reverse.py with huggingface_hub
Browse files
layer_diff_dataset/reverse.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import shutil
|
| 3 |
+
from tqdm import tqdm
|
| 4 |
+
import cv2
|
| 5 |
+
folder_path = '/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/try/gt'
|
| 6 |
+
folder_path_ = '/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/try/gt_reverse'
|
| 7 |
+
os.makedirs(folder_path_,exist_ok=True)
|
| 8 |
+
file_list = os.listdir(folder_path)
|
| 9 |
+
file_list = [i for i in file_list if i.endswith('.png')]
|
| 10 |
+
file_list.sort()
|
| 11 |
+
|
| 12 |
+
pbar = tqdm(enumerate(file_list),total=len(file_list))
|
| 13 |
+
for i, image_name in pbar:
|
| 14 |
+
gt = cv2.imread(os.path.join(folder_path,image_name),cv2.IMREAD_GRAYSCALE)
|
| 15 |
+
gt = cv2.resize((255-gt),(512,512))
|
| 16 |
+
cv2.imwrite(os.path.join(folder_path_,image_name),gt)
|
| 17 |
+
|