This package wraps the rapidocr library into an API, implemented using FastAPI + uvicorn.
It is positioned as an API interface for quickly calling rapidocr, and does not take multi-process handling of concurrent requests into account. If you have such needs, you can take a look at gunicorn and similar tools.
In rapidocr_api>=0.1.0, model parameters can be passed through environment variables: det_model_path, cls_model_path, rec_model_path; parameters can also be passed in the interface to control whether to use the three parts of models: detection, orientation classification and recognition; for specific calls, see the documentation below.
# Start with default parametersrapidocr_api
# Specify parameters: port and number of processes;rapidocr_api-ip0.0.0.0-p9005-workers2# Specify modelsexportdet_model_path=/mnt/sda1/models/PP-OCRv4/ch_PP-OCRv4_det_server_infer.onnx
exportrec_model_path=/mnt/sda1/models/PP-OCRv4/ch_PP-OCRv4_rec_server_infer.onnx
rapidocr_api-ip0.0.0.0-p9005-workers2
gitclonehttps://github.com/RapidAI/RapidOCR.git
cdapi
# Build method 1: use the host's networkdockerbuild-t="rapidocr_api:0.1.4"--networkhost.
# Build method 2: use the proxy on the hostdockerbuild-trapidocr_api:0.1.4--networkhost--build-argHTTP_PROXY=http://127.0.0.1:8888--build-argHTTPS_PROXY=http://127.0.0.1:8888.
dockerexec-itrapidocr_api/bin/bash
cd/usr/local/lib/python3.10/site-packages/rapidocr_api
...
# Modify the parameter filevi/usr/local/lib/python3.10/site-packages/rapidocr_onnxruntime/config.yaml
# Type exit to quit after making the changes