How do I approach PaddleOCR “ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()”?

This is the inference code that I’ve used for the text detection task using paddle. I referred to the following site for the code: https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_en/whl_en.md

from paddleocr import PaddleOCR,draw_ocr


ocr = PaddleOCR(det_model_dir="/content/drive/MyDrive/paddleocr/Multilingual_PP-OCRv3_det_infer/") # need to run only once to download and load model into memory
img_path="/content/drive/MyDrive/paddleocr/inference_images/494__2334178__494.jpg"
result = ocr.ocr(img_path,rec=False)
print(f"result: {result}")


for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)

# draw result
from PIL import Image
result = result[0]
image = Image.open(img_path).convert('RGB')
im_show = draw_ocr(image, result, txts=None, scores=None, font_path="/content/drive/MyDrive/paddleocr/PaddleOCR/doc/fonts/nepali.ttf")
im_show = Image.fromarray(im_show)
im_show.save('/content/drive/MyDrive/paddleocr/detection_result.jpg')

Image
google_colab_inference_code_image

  • 1

    Please post the error as text, not a screenshot.

    – 

Leave a Comment