-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre_data.py
64 lines (52 loc) · 1.96 KB
/
pre_data.py
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
50
51
52
53
54
55
56
57
58
59
60
61
#coding=utf8
import os
import numpy as np
from PIL import Image
# 取得目录下面的文件列表
def get_dir_img_list(dir_proc, recusive=True):
file_list = []
for file in os.listdir(dir_proc):
if os.path.isdir(os.path.join(dir_proc, file)):
if (recusive):
file_list.append(get_dir_img_list(os.path.join(dir_proc, file), recusive))
continue
#img = os.path.join(dir_proc, file)
img = dir_proc + "/" + file
file_list.append(img)
return file_list
palette=[]
palette[:3*21]=np.array([[0, 0, 0],
[128, 0, 0],
[0, 128, 0],
[128, 128, 0],
[0, 0, 128],
[128, 0, 128],
[0, 128, 128],
[128, 128, 128],
[64, 0, 0],
[192, 0, 0],
[64, 128, 0],
[192, 128, 0],
[64, 0, 128],
[192, 0, 128],
[64, 128, 128],
[192, 128, 128],
[0, 64, 0],
[128, 64, 0],
[0, 192, 0],
[128, 192, 0],
[0, 64, 128]], dtype='uint8').flatten()
if __name__=="__main__":
pasing_dir = "I:/LIP-dataset/TrainVal_parsing_annotations/TrainVal_parsing_annotations/train_segmentations"
pasing_img_list = get_dir_img_list(pasing_dir)
img_dir = "I:/LIP-dataset/TrainVal_images/TrainVal_images/train_images"
img_list = get_dir_img_list(img_dir)
for img_path in pasing_img_list:
img = Image.open(img_path)
img.putpalette(palette)
img.show()
#break
for img_path in img_list:
img = Image.open(img_path)
img.show()
#break