### jupyter notebook 中执行代码指定GPU
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="0"
### resize image
def resize_image(ori_dir, des_dir,classes):
for cc in classes:
subclass_dir = os.path.join(ori_dir,cc)
subclass_des_dir = os.path.join(des_dir,cc)
imglist = os.listdir(subclass_dir)
num = len(imglist)
for k in range(0,num):
currentpath = subclass_dir +"/"+imglist[k]
im = Image.open(currentpath)
x_s=256
y_s=256
temp = im
out = temp.resize((x_s,y_s),Image.ANTIALIAS)
out.save(subclass_des_dir+"/"+str(imglist[k]))
ori_path = ' '
des_path = ''
classes = [' ', ' ']
des_path = resize_image(ori_path, des_path, classes)
### 将二维list变为1维list
from itertools import chain
a = [[1,2,3],[4,5,6],[7,8,9]]
b = list(chain.from_iterable(a))
print(b)
# b = [1,2,3,4,5,6,7,8,9]