属性错误模块-pil-image-无属性抗锯齿

问题描述 投票:0回答:1

我正在使用 opencv 和 yolo 解决自动车牌检测问题。 当我将 numpy 数组传递给 easyocr readtext 模块时,出现以下错误

    import easyocr
    reader = easyocr.Reader(['en'], gpu=False)
    
    print(type(license_plate_crop)) # <class 'numpy.ndarray'>
    print(license_plate_crop)
    detections = reader.readtext(license_plate_crop)

这是我遇到的错误

line 619, in get_image_list
    crop_img,ratio = compute_ratio_and_resize(crop_img,width,height,model_height)
  File "/home/pranith_dev/Desktop/Datavoice/Automatic-License-Plate-Recognition-using-YOLOv8/dev-venv/lib/python3.10/site-packages/easyocr/utils.py", line 582, in compute_ratio_and_resize
    img = cv2.resize(img,(int(model_height*ratio),model_height),interpolation=Image.ANTIALIAS)
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

我尝试根据网上的解决方案将枕头版本从10.0.0降级到9.5或9.4,但问题仍然存在,以下是输出

<class 'numpy.ndarray'>
[[255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 ...
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]]
Illegal instruction
python computer-vision ocr yolo
1个回答
0
投票

欢迎普拉尼斯!

Github 上的

EasyOCR 项目列出了对utils.py

的提交:
Update utils.py。显然,Pillow 10 中的 Image.Resampling.LANCZOS
 取代了 
PIL.Image.ANTIALIAS

您可以使用

pip list | grep pillow

 检查您自己的 Pillow 版本。
确保您有:

    包含上述提交的 EasyOCR 版本(并且仍然与您正在使用的 Python
  • 3.10
    兼容)
  • 或保留您的 EasyOCR 版本,但相应地降级您的 Pillow 版本,以便它具有
  • PIL.Image.ANTIALIAS
    
    
© www.soinside.com 2019 - 2024. All rights reserved.