OSError im_show = draw_ocr(image, boxes, txts, scores, font_path='./fonts/simfang.ttf') #8839
shubhmehta10
started this conversation in
General
Replies: 2 comments
-
i am facing the same problem. Did you find a solution? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am facing error in the paddleocr code that is mentioned in the Quickstart menu.
Here is the error:
OSError Traceback (most recent call last)
Cell In[17], line 7
5 txts = [line[1][0] for line in rresult]
6 scores = [line[1][1] for line in rresult]
----> 7 im_show = draw_ocr(image, boxes, txts, scores, font_path='./fonts/simfang.ttf')
8 im_show = Image.fromarray(im_show)
9 im_show.save('result.jpg')
File ~/miniconda3/envs/paddle_env/lib/python3.8/site-packages/paddleocr/tools/infer/utility.py:389, in draw_ocr(image, boxes, txts, scores, drop_score, font_path)
387 if txts is not None:
388 img = np.array(resize_img(image, input_size=600))
--> 389 txt_img = text_visual(
390 txts,
391 scores,
392 img_h=img.shape[0],
393 img_w=600,
394 threshold=drop_score,
395 font_path=font_path)
396 img = np.concatenate([np.array(img), np.array(txt_img)], axis=1)
397 return img
File ~/miniconda3/envs/paddle_env/lib/python3.8/site-packages/paddleocr/tools/infer/utility.py:533, in text_visual(texts, scores, img_h, img_w, threshold, font_path)
531 font_size = 20
532 txt_color = (0, 0, 0)
--> 533 font = ImageFont.truetype(font_path, font_size, encoding="utf-8")
535 gap = font_size + 5
536 txt_img_list = []
File ~/miniconda3/envs/paddle_env/lib/python3.8/site-packages/PIL/ImageFont.py:1008, in truetype(font, size, index, encoding, layout_engine)
1005 return FreeTypeFont(font, size, index, encoding, layout_engine)
1007 try:
-> 1008 return freetype(font)
1009 except OSError:
1010 if not is_path(font):
File ~/miniconda3/envs/paddle_env/lib/python3.8/site-packages/PIL/ImageFont.py:1005, in truetype..freetype(font)
1004 def freetype(font):
-> 1005 return FreeTypeFont(font, size, index, encoding, layout_engine)
File ~/miniconda3/envs/paddle_env/lib/python3.8/site-packages/PIL/ImageFont.py:255, in FreeTypeFont.init(self, font, size, index, encoding, layout_engine)
253 load_from_bytes(f)
254 return
--> 255 self.font = core.getfont(
256 font, size, index, encoding, layout_engine=layout_engine
257 )
258 else:
259 load_from_bytes(font)
OSError: cannot open resource
Can someone help me out with this ?
Beta Was this translation helpful? Give feedback.
All reactions