我正在尝试将一些JPG加载到GAN中,并且我已经导入了train_test_split。我的桌面上有一个名为“ input_data”的培训/测试数据文件夹。该文件夹内有两个子文件夹,即Test和Train。在“测试”和“训练”文件夹中是Images1和Images2。
我在这里做错了什么?
错误:
Traceback (most recent call last):
File "gan3.py", line 31, in <module>
with open(path, 'rb') as fh:
IsADirectoryError: [Errno 21] Is a directory: 'input_data/Train'
代码:
def loadImages(path):
# return array of images
imagesList = listdir(path)
loadedImages = []
for image in imagesList:
img = PImage.open(path + image)
loadedImages.append(img)
return loadedImages
path = "input_data"
for filename in os.listdir(path):
content = open(os.path.join(path, filename), mode='rb').read()
with open(path, 'rb') as fh:
# your images in an array
imgs = loadImages(path)
def loadImages():
(x_train, y_train), (x_test, y_test) = loadImages()
x_train = (x_train.astype(np.float32) - 127.5)/127.5
x_train = x_train.reshape(60000, 784)
return (x_train, y_train, x_test, y_test)