Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
from django.http import HttpRequest
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import time
from paddleocr import PaddleOCR
@csrf_exempt
def recognize(request):
print("ping() is called")
return HttpResponse("{}",
content_type="application/json; encoding=utf-8",
status=200)
[Fri Mar 15 11:55:55.282321 2024] [wsgi:error] [pid 3872:tid 1208] [client 10.235.59.122:59096] Error: Can not import paddle core while this file exists: C:\Python310\lib\site-packages\paddle\base\libpaddle.pyd\r
用apache + wsgi + jdango部署的web service,提供一个API来使用PaddleOCR识别图像
API涉及的代码如下(ocr识别图片的代码已移除,仅保留这句发生问题的代码“from paddleocr import PaddleOCR”):
此django程序用python本地启用后(python manage.py runserver),API调用成功(ocr识别图片代码不删除的话,也可成功识别图像)。
但部署到Apache后,调用API时apache报错,报错log如下:
但把那句from paddleocr import PaddleOCR删除的话,API调用也是成功的 (也就是说,我的Django程序在Apache中的wsgi配置应该是没问题的)
在Apache的httpd.conf文件中,wsgi相关配置如下(相关路径配置确认都没问题):