加载 skimage 相机图像时出错
Error while loading skimage camera images
我正在尝试 a crash course on NumPy for images 而这一行抛出了一个错误:
>> from skimage import data
>> camera = data.camera()
以下是相同的错误跟踪:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-8539ecc9e129> in <module>
----> 1 data.camera()
~/.local/lib/python3.6/site-packages/skimage/data/__init__.py in camera()
107 Camera image.
108 """
--> 109 return _load("camera.png")
110
111
~/.local/lib/python3.6/site-packages/skimage/data/__init__.py in _load(f, as_gray)
94 # we lazy import it here
95 from ..io import imread
---> 96 return imread(_os.path.join(data_dir, f), plugin='pil', as_gray=as_gray)
97
98
~/.local/lib/python3.6/site-packages/skimage/io/_io.py in imread(fname, as_gray, plugin, **plugin_args)
46
47 with file_or_url_context(fname) as fname:
---> 48 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
49
50 if not hasattr(img, 'ndim'):
~/.local/lib/python3.6/site-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
208 (plugin, kind))
209
--> 210 return func(*args, **kwargs)
211
212
~/.local/lib/python3.6/site-packages/skimage/io/_plugins/pil_plugin.py in imread(fname, dtype, img_num, **kwargs)
34 with open(fname, 'rb') as f:
35 im = Image.open(f)
---> 36 return pil_to_ndarray(im, dtype=dtype, img_num=img_num)
37 else:
38 im = Image.open(fname)
~/.local/lib/python3.6/site-packages/skimage/io/_plugins/pil_plugin.py in pil_to_ndarray(image, dtype, img_num)
64 while 1:
65 try:
---> 66 image.seek(i)
67 except EOFError:
68 break
~/.local/lib/python3.6/site-packages/PIL/PngImagePlugin.py in seek(self, frame)
737
738 def seek(self, frame):
--> 739 if not self._seek_check(frame):
740 return
741 if frame < self.__frame:
~/.local/lib/python3.6/site-packages/PIL/ImageFile.py in _seek_check(self, frame)
304 raise EOFError("attempt to seek outside sequence")
305
--> 306 return self.tell() != frame
307
308
~/.local/lib/python3.6/site-packages/PIL/PngImagePlugin.py in tell(self)
825
826 def tell(self):
--> 827 return self.__frame
828
829 def load_prepare(self):
AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'
这里有什么问题?我在 Ubuntu 18.04 上使用 skimage 0.16.2、Python 3.6.9。 3 LTS.
我对 Scikit-Learn 有丰富的经验,但对图像处理和 skimage 还是个新手。
这是最新版本 Pillow (7.1.0) 的错误。他们已经 rushing to fix it and you should soon be able to fix the problem by doing pip install -U Pillow
. Monitor this page 用于 7.1 之后的下一个版本。
您也可以安装以前的版本,pip install Pillow==7.0.0
。
我正在尝试 a crash course on NumPy for images 而这一行抛出了一个错误:
>> from skimage import data
>> camera = data.camera()
以下是相同的错误跟踪:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-8539ecc9e129> in <module>
----> 1 data.camera()
~/.local/lib/python3.6/site-packages/skimage/data/__init__.py in camera()
107 Camera image.
108 """
--> 109 return _load("camera.png")
110
111
~/.local/lib/python3.6/site-packages/skimage/data/__init__.py in _load(f, as_gray)
94 # we lazy import it here
95 from ..io import imread
---> 96 return imread(_os.path.join(data_dir, f), plugin='pil', as_gray=as_gray)
97
98
~/.local/lib/python3.6/site-packages/skimage/io/_io.py in imread(fname, as_gray, plugin, **plugin_args)
46
47 with file_or_url_context(fname) as fname:
---> 48 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
49
50 if not hasattr(img, 'ndim'):
~/.local/lib/python3.6/site-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
208 (plugin, kind))
209
--> 210 return func(*args, **kwargs)
211
212
~/.local/lib/python3.6/site-packages/skimage/io/_plugins/pil_plugin.py in imread(fname, dtype, img_num, **kwargs)
34 with open(fname, 'rb') as f:
35 im = Image.open(f)
---> 36 return pil_to_ndarray(im, dtype=dtype, img_num=img_num)
37 else:
38 im = Image.open(fname)
~/.local/lib/python3.6/site-packages/skimage/io/_plugins/pil_plugin.py in pil_to_ndarray(image, dtype, img_num)
64 while 1:
65 try:
---> 66 image.seek(i)
67 except EOFError:
68 break
~/.local/lib/python3.6/site-packages/PIL/PngImagePlugin.py in seek(self, frame)
737
738 def seek(self, frame):
--> 739 if not self._seek_check(frame):
740 return
741 if frame < self.__frame:
~/.local/lib/python3.6/site-packages/PIL/ImageFile.py in _seek_check(self, frame)
304 raise EOFError("attempt to seek outside sequence")
305
--> 306 return self.tell() != frame
307
308
~/.local/lib/python3.6/site-packages/PIL/PngImagePlugin.py in tell(self)
825
826 def tell(self):
--> 827 return self.__frame
828
829 def load_prepare(self):
AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'
这里有什么问题?我在 Ubuntu 18.04 上使用 skimage 0.16.2、Python 3.6.9。 3 LTS.
我对 Scikit-Learn 有丰富的经验,但对图像处理和 skimage 还是个新手。
这是最新版本 Pillow (7.1.0) 的错误。他们已经 rushing to fix it and you should soon be able to fix the problem by doing pip install -U Pillow
. Monitor this page 用于 7.1 之后的下一个版本。
您也可以安装以前的版本,pip install Pillow==7.0.0
。