我正在尝试遍历目录并使用 scikit-image 调整每个图像的大小,但我不断收到以下错误:
b'scene01601.png'
Traceback (most recent call last):
File "preprocessingdatacopy.py", line 16, in <module>
image_resized = resize(filename, (128, 128))
File "/home/briannagopaul/PycharmProjects/DogoAutoencoder/venv/lib/python3.6/site-packages/skimage/transform/_warps.py", line 104, in resize
input_shape = image.shape
AttributeError: 'str' object has no attribute 'shape'
我的代码:
import skimage
from sklearn import preprocessing
from skimage import data, color
import os
from skimage.transform import resize, rescale
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import os
directory_in_str = "/home/briannagopaul/imagemickey/"
directory = os.fsencode(directory_in_str)
for file in os.listdir(directory):
print(file)
filename = os.fsdecode(file)
if filename.endswith(".png"):
image_resized = resize(filename, (128, 128))
img = mpimg.imread(file)
imgplot = plt.imshow(img)
plt.show()
filename.shape()