draw_ocr inhomogeneous shape after 1 dimensions #14857
Replies: 2 comments
-
I'm using last version of PaddleOCR |
Beta Was this translation helpful? Give feedback.
-
The error "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions." suggests that there is an issue with how the data is structured before passing it to 🔍 Possible Issues and Solutions:1. Incorrect List IndexingYour code contains: boxes = [line[0] for line in result]
txts = [line[0][1][0] for line in result] # Incorrect indexing
scores = [line[0][1][1] for line in result] # Incorrect indexing Here, [
[ [[x1, y1], [x2, y2], [x3, y3], [x4, y4]], ('Detected Text', Confidence_Score) ]
] Fix it by correcting the indexing: txts = [line[1][0] for line in result] # Extracting the detected text
scores = [line[1][1] for line in result] # Extracting confidence score 2. Missing Font PathIn your code: font = ImageFont.load_default()
im_show = draw_ocr(image, boxes, txts, scores, font_path=font) The Fix it by providing a proper font path: im_show = draw_ocr(image, boxes, txts, scores, font_path='/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf') If you're using Google Colab, install a font like DejaVu first: !apt-get install fonts-dejavu
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" 3. Ensure
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🔎 Search before asking
🐛 Bug (问题描述)
Hi everyone, I'm new with PaddleOcr and I was testing it with my image
I used this code to OCR the Image
Perform OCR on the image
I got this result
But I need to show the image with showing OCR data into image
I tried this one
But I got this error
🏃♂️ Environment (运行环境)
I'm using Google Colab
🌰 Minimal Reproducible Example (最小可复现问题的Demo)
That's example image
Beta Was this translation helpful? Give feedback.
All reactions