forked from zlckanata/DeepGlobe-Road-Extraction-Challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaste_image.py
More file actions
49 lines (31 loc) · 1.33 KB
/
Copy pathpaste_image.py
File metadata and controls
49 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import argparse
import os
import mmap
import cv2
import time
import numpy as np
from skimage import io
from tqdm import tqdm
tqdm.monitor_interval = 0
def paste():
folders = ['results/dink34_test_dataloader/images',]
for folder in folders:
new_folder = folder+'_paste'
os.makedirs(new_folder, exist_ok=True)
with open('data/deepglobe/img/offical_test.txt') as file:
imagelist = file.readlines()
image_id = list(map(lambda x: x[:-1], imagelist))
for id in tqdm(image_id):
id = id.split('/')[-1].replace('.jpg', '').replace('_sat', '')
img_0_0 = cv2.imread(folder+'/'+id+'_0_0_sat.png', cv2.IMREAD_COLOR)
img_0_1 = cv2.imread(folder+'/'+id+'_0_1_sat.png', cv2.IMREAD_COLOR)
img_1_0 = cv2.imread(folder+'/'+id+'_1_0_sat.png', cv2.IMREAD_COLOR)
img_1_1 = cv2.imread(folder+'/'+id+'_1_1_sat.png', cv2.IMREAD_COLOR)
img_0 = np.concatenate((img_0_0, img_1_0), axis = 0)
img_1 = np.concatenate((img_0_1, img_1_1), axis = 0)
img = np.concatenate((img_0, img_1), axis = 1)
cv2.imwrite(new_folder+'/'+id+'_mask.png', img)
# import pdb
# pdb.set_trace()
if __name__ == "__main__":
paste()