gpt4 book ai didi

caffe - TypeError : self. _open() 得到了一个意外的关键字参数 'as_grey' python

转载 作者:行者123 更新时间:2023-12-02 16:50:22 25 4
gpt4 key购买 nike

我的一位同事在对图像进行分类时在 python 服务中遇到错误。下面是错误跟踪日志

 File "nsfw.py", line 7, in <module>
score = classifier.get_score('8.jpg')
File "/home/arunsharma/.local/lib/python3.6/site-packages/open_nsfw_python3/__init__.py", line 104, in get_score
image_data, caffe_transformer=caffe_transformer, caffe_net=nsfw_net, output_layers=['prob'])


File "/home/arunsharma/.local/lib/python3.6/site-packages/open_nsfw_python3/__init__.py", line 52, in caffe_preprocess_and_compute
image = caffe.io.load_image(img_data_rs)
File "/usr/lib/python3/dist-packages/caffe/io.py", line 301, in load_image
img = skimage.img_as_float(skimage.io.imread(filename, as_grey=not color)).astype(np.float32)
File "/home/arunsharma/.local/lib/python3.6/site-packages/skimage/io/_io.py", line 48, in imread
img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
File "/home/arunsharma/.local/lib/python3.6/site-packages/skimage/io/manage_plugins.py", line 210, in call_plugin
return func(*args, **kwargs)
File "/home/arunsharma/.local/lib/python3.6/site-packages/skimage/io/_plugins/imageio_plugin.py", line 10, in imread
return np.asarray(imageio_imread(*args, **kwargs))
File "/home/arunsharma/.local/lib/python3.6/site-packages/imageio/core/functions.py", line 264, in imread
reader = read(uri, format, "i", **kwargs)
File "/home/arunsharma/.local/lib/python3.6/site-packages/imageio/core/functions.py", line 186, in get_reader
return format.get_reader(request)
File "/home/arunsharma/.local/lib/python3.6/site-packages/imageio/core/format.py", line 164, in get_reader
return self.Reader(self, request)
File "/home/arunsharma/.local/lib/python3.6/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'

Here是他用过的图书馆。他首先安装了caffe库并升级了skimage库。但仍然没有运气。

任何帮助将不胜感激。

代码:

from open_nsfw_python3 import NSFWClassifier

classifier = NSFWClassifier()

score = classifier.get_score('image.jpg')

print(score)

他在执行 get_score 时得到错误。

最佳答案

pycaffe 依赖skimage 做图像预处理。随着 skimage 在版本中的发展,他们决定将一些函数参数从 as_grey 重命名为 as_gray

但是,Caffe 仍然使用as_grey:

https://github.com/BVLC/caffe/blob/9b891540183ddc834a02b2bd81b31afae71b2153/python/caffe/io.py#L302

您有两个选择,安装旧版本的 skimage,或更改 pycaffe 中的那行代码,以使用 as_gray

关于caffe - TypeError : self. _open() 得到了一个意外的关键字参数 'as_grey' python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58993530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com