英文:
Not able to import paddleocr library on Google Colab
问题
我无法在成功安装了paddlepaddle和paddleocr之后,在Google Colab上导入paddleocr库。它出现了如下错误:
**from paddleocr import PaddleOCR, draw_ocr**
错误:无法导入paddle核心,因为存在以下文件:/usr/local/lib/python3.10/dist-packages/paddle/fluid/libpaddle.so
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-e16532d3d475> in <cell line: 1>()
----> 1 from paddleocr import PaddleOCR, draw_ocr
2 import os
3 import cv2
4 import matplotlib.pyplot as plt
5 get_ipython().run_line_magic('matplotlib', 'inline')
8 frames
/usr/local/lib/python3.10/dist-packages/paddle/fluid/core.py in <module>
267
268 try:
--> 269 from . import libpaddle
270
271 if avx_supported() and not libpaddle.is_compiled_with_avx():
ImportError: libssl.so.1.1: 无法打开共享对象文件:没有那个文件或目录
之前一切正常,但今天我无法导入paddleOCR。感谢社区对此问题的帮助。
英文:
I am not able to import paddleocr library on Google Colab after the install of paddlepaddle and paddleocr successfully. It hits the error as shown below:
**from paddleocr import PaddleOCR, draw_ocr**
Error: Can not import paddle core while this file exists: /usr/local/lib/python3.10/dist-packages/paddle/fluid/libpaddle.so
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-e16532d3d475> in <cell line: 1>()
----> 1 from paddleocr import PaddleOCR, draw_ocr
2 import os
3 import cv2
4 import matplotlib.pyplot as plt
5 get_ipython().run_line_magic('matplotlib', 'inline')
8 frames
/usr/local/lib/python3.10/dist-packages/paddle/fluid/core.py in <module>
267
268 try:
--> 269 from . import libpaddle
270
271 if avx_supported() and not libpaddle.is_compiled_with_avx():
ImportError: libssl.so.1.1: cannot open shared object file: No such file or directory
Previously, everything was okay but I am not able to import paddleOCR today. Appreciate the community help on this issue.
答案1
得分: 0
使用以下步骤,我成功在Google Colab中运行了PaddleOCR:
-
转到"Runtime"选项卡,选择"Change runtime type",在"Hardware accelerator"下选择"GPU"。
-
在Google Colab的
content
部分上传要分析的图像。 -
使用
pip
下载PaddleOCR模块:
!pip install paddlepaddle-gpu
!pip install paddleocr
- 使用Bash下载
libssl1.1
:
!wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
!sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
- 从GitHub克隆PaddleOCR存储库以使用字体:
!git clone https://github.com/PaddlePaddle/PaddleOCR
- 运行代码块来测试PaddleOCR是否正常工作。代码块来自PaddleOCR的pypi页面中的项目描述部分:
from paddleocr import PaddleOCR, draw_ocr
from PIL import Image
from IPython import display
img_path = '/content/test_img.PNG'
ocr = PaddleOCR(lang='en')
result = ocr.ocr(img_path, rec=False)
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
result = result[0]
image = Image.open(img_path).convert('RGB')
im_show = draw_ocr(image, result, txts=None, scores=None, font_path='/content/PaddleOCR/StyleText/fonts/ko_standard.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
display.Image('result.jpg')
英文:
Using the following steps, I was able to get PaddleOCR to run in Google Colab:
-
Go the the "Runtime" tab, select "Change runtime type" and under "Hardware accelerator" select "GPU".
-
Upload the image to be analyzed in the
content
section of Google Colab. -
Download the PaddleOCR modules using
pip
:
!pip install paddlepaddle-gpu
!pip install paddleocr
- Download
libssl1.1
using Bash:
!wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
!sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
- Clone the PaddleOCR repo from GitHub to use the fonts:
!git clone https://github.com/PaddlePaddle/PaddleOCR
- Run a codeblock to test that PaddleOCR is working. The codeblock is from the project description section on PaddleOCR's pypi page:
from paddleocr import PaddleOCR, draw_ocr
from PIL import Image
from IPython import display
img_path = '/content/test_img.PNG'
ocr = PaddleOCR(lang='en')
result = ocr.ocr(img_path,rec=False)
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
result = result[0]
image = Image.open(img_path).convert('RGB')
im_show = draw_ocr(image, result, txts=None, scores=None, font_path='/content/PaddleOCR/StyleText/fonts/ko_standard.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
display.Image('result.jpg')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论