安装
docker run -p 80:80 -p 8866:8866 --name ppocr --env USER_PASSWD="123456" -v /home/paddle:/home/paddle -itd registry.baidubce.com/paddlepaddle/paddle:2.1.3-jupyter
http://192.168.100.49/
jovyan
123456
docker exec -it ppocr /bin/bash
pip install "paddleocr>=2.0.1"
sudo apt update
sudo apt install libgl1-mesa-glx -y
sudo apt-get install libglib2.0-0 -y
#选项 6
#选项 70
测试
paddleocr --image_dir /home/paddle/a.png --use_angle_cls true --use_gpu false
安装
pip3 install paddlepaddle==2.3.0rc0 -i https://mirror.baidu.com/pypi/simple
pip3 install paddlehub==2.0.0rc0 -i https://mirror.baidu.com/pypi/simple
pip3 install shapely -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install pyclipper -i https://pypi.tuna.tsinghua.edu.cn/simple
pip uninstall protobuf
pip install protobuf==3.19.0
测试
hub run chinese_ocr_db_crnn_server --input_path /home/paddle/a.png --visualization=True --output_dir='ocr_result'
启动服务
nohup hub serving start -m chinese_ocr_db_crnn_server &
API请求
OkHttpParams params = new OkHttpParams();
params.addHeads("Content-type", "application/json");
Map im = new HashMap();
List<String> ls = new ArrayList<>();
ls.add(OkFile.read("E:\\code\\a.txt"));
im.put("images", ls);
params.addBody(OkJson.toJsonStr(im), MediaType.get("application/json"));
OkHttp.HttpStatus httpStatus =OkHttp.tool.post("http://192.168.100.49:8866/predict/chinese_ocr_db_crnn_server", params);
手写OCR
相关文档
手写数据库下载
https://aistudio.baidu.com/datasetdetail/102884
参考文档
https://www.jianshu.com/p/e2d2857d7f59
评估预训练模型
python tools/eval.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model="/home/paddle/train/OCRv3/best_accuracy"
开始训练识别模型
python tools/train.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml
评估finetune效果
python tools/eval.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model="/home/paddle/output/OCRv3/best_accuracy"
转化为推理模型
python tools/export_model.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model="/home/paddle/output/OCRv3/best_accuracy" Global.save_inference_dir="/home/paddle/inference/rec_ppocrv3/"
推理预测
python tools/infer/predict_rec.py --image_dir="/home/paddle/b.png" --rec_model_dir="/home/paddle/inference/rec_ppocrv3/Student"