Last active
October 9, 2018 09:11
-
-
Save lartpang/bda9bdba0cc393b2ae5dc0908237e482 to your computer and use it in GitHub Desktop.
获取文件夹下文件名/读取放缩图片/存储数据
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 获取文件名 | |
import os | |
all_file = [] | |
def file_name(path): | |
for file_name in os.listdir(path): | |
all_file.append(file_name) | |
path = 'test/' | |
file_name(path) | |
num_image_train = len(all_file) | |
# 导入训练数据 | |
x_train = np.zeros((num_image_train, 224, 224, 3)) | |
for i in range(num_image_train): | |
img = Image.open(path + all_file[i]) | |
img_resize = img.resize((224, 224)) | |
x_train[i] = np.array(img_resize) | |
np.save("x_train.npy", x_train) | |
print("训练数据导入完毕") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment