-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare_img_0.py
44 lines (35 loc) · 1.05 KB
/
prepare_img_0.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
#!/usr/bin/env python3.5
# coding=utf-8
'''
@date = '17/12/1'
@author = 'lynnchan'
@email = '[email protected]'
'''
import os
from PIL import Image
from gconfig import *
train_path = Train_Data_Path
test_path = Test_Data_Path
def format_list(path):
for i in os.listdir(path):
dic_i = os.path.join(path, i)
if os.path.isfile(dic_i) and (os.path.splitext(i)[1] == '.jpg' or os.path.splitext(i)[1] == '.JPG'):
img = Image.open(dic_i).convert('RGB')
img.save(dic_i)
def format_img():
if type(train_path) !=list:
format_list(train_path)
print('Successfully format_img.')
else:
for i in train_path:
format_list(i)
print('Successfully format list img: '+i)
if type(test_path) != list:
format_list(test_path)
print('Successfully format_img.')
else:
for i in test_path:
format_list(i)
print('Successfully format list img: '+i)
if __name__ == '__main__':
format_img()