First convFirst convert it to image object by Image.fromarray then use convertert it to image First
AttributeError: ‘numpy.ndarray‘ object has no attribute ‘convert'
Convert it to an image object by Image.fromarray then use convert
from PIL import Image
grad2__ = Image.fromarray(grad2_)
-----------------------------------------
hash0 = imagehash.average_hash(grad2__)
or
image = grad2__.convert("RGB")
这篇博客讨论了在使用PIL库处理图像时遇到的问题。作者尝试将numpy数组转换为Image对象,然后进行颜色转换,但遇到了'numpy.ndarray'对象没有'convert'属性的错误。解决方案可能涉及到正确地使用Image.fromarray方法和图像的convert方法。博客还提到了使用average_hash进行图像哈希和RGB转换的操作。


被折叠的 条评论
为什么被折叠?



