ImportError: cannot import name ‘compare

ImportError: cannot import name ‘compare,第1张

令人头痛的问题:

Traceback (most recent call last):
  File "test.py", line 15, in
    from util.visualizer import Visualizer
  File "D:\wGAN\mc-gan2\util\visualizer.py", line 15, in
    from skimage.measure import compare_ssim as ssim
ImportError: cannot import name 'compare_ssim' from 'skimage.measure' (D:\Anaconda3\envs\torch\lib\site-packages\skimage
\measure\__init__.py)

原因和解决办法:

scikit-image升级后改变了库函数的结构,函数skimage.measure.compare_ssim已经被skimage.metrics.structural_similarity取代。

参考:

Is there a way to import compare_ssim for python IDLE? - Stack Overflow

As per - https://github.com/scikit-image/scikit-image/blob/b38fd6f02917db2965f5faf2e6e18fc197b8d6c8/skimage/metrics/_structural_similarity.py#L17

versionchanged:: 0.16 This function was renamed from skimage.measure.compare_ssim to skimage.metrics.structural_similarity

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/725375.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存