image_match TypeError: _open() got an unexpected keyword argument 'as_grey'

mac os python3.7跑image_match库的demo时报错,traceback如下:


Traceback (most recent call last):
  File "/Users/wangjinyu/PycharmProjects/machine-learning/image.py", line 3, in 
    a = gis.generate_signature('https://www.baidu.com/img/bd_logo1.png')
  File "/Users/wangjinyu/PycharmProjects/machine-learning/image-match/image_match/goldberg.py", line 160, in generate_signature
    im_array = self.preprocess_image(path_or_image, handle_mpo=self.handle_mpo, bytestream=bytestream)
  File "/Users/wangjinyu/PycharmProjects/machine-learning/image-match/image_match/goldberg.py", line 240, in preprocess_image
    return imread(image_or_path, as_grey=True)
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/skimage/io/_io.py", line 48, in imread
    img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/skimage/io/manage_plugins.py", line 210, in call_plugin
    return func(*args, **kwargs)
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/skimage/io/_plugins/imageio_plugin.py", line 10, in imread
    return np.asarray(imageio_imread(*args, **kwargs))
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/imageio/core/functions.py", line 264, in imread
    reader = read(uri, format, "i", **kwargs)
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/imageio/core/functions.py", line 186, in get_reader
    return format.get_reader(request)
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/imageio/core/format.py", line 164, in get_reader
    return self.Reader(self, request)
  File "/Users/wangjinyu/.pyenv/versions/ai/lib/python3.7/site-packages/imageio/core/format.py", line 214, in __init__
    self._open(**self.request.kwargs.copy())
TypeError: _open() got an unexpected keyword argument 'as_grey'

主要错误信息:TypeError: _open() got an unexpected keyword argument 'as_grey'

追查了半天,发现是项目中的一个参数写错了,as_gray,写成了as_grey,所以改一下参数就行了。

修改/mage-match/image_match/goldberg.py文件的第240行,改完之后正常了。

elif type(image_or_path) in string_types or \
     type(image_or_path) is text_type:
    # return imread(image_or_path, as_grey=True)
    #将as_grey改为as_gray
    return imread(image_or_path, as_gray=True)

本来想试着提叫一个pull request,发现已经有人提了。

https://github.com/EdjoLabs/image-match/pull/117

ps1:几次追踪bug的经历发现pycharm代码追踪有时候不太准,偶尔分不清具体哪个类对应的那个方法。

ps2:直接pip安装image-match总是报错,将项目clone下来后,再项目目录中pip install .可以正常安装。

ps3:如果不修改as_gray参数,可以用Python2.7的环境跑项目。会报一个警告:

/Users/wangjinyu/.pyenv/versions/python2.7.6/lib/python2.7/site-packages/skimage/io/_io.py:49: UserWarning: `as_grey` has been deprecated in favor of `as_gray`
  warn('`as_grey` has been deprecated in favor of `as_gray`')

 

你可能感兴趣的:(python,算法)