Skip to main content

text detection + text recognition

Project description


pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 -f
pip install --upgrade ultocr  # install our project with package

# for inference phase
from ultocr.inference import OCR
from PIL import Image
model = OCR(det_model='DB', reg_model='MASTER')
image ='..')  # the path of image
result = model.get_result(image)

Or view in google colab demo


git clone
pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 -f
pip install -r requirements.txt
bash scripts/

Prepare data

Pretrained model

Model size(MB)
DB 140


Custom params in each config file of config folder then:

Single gpu training:

python --config config/db_resnet50.yaml --use_dist False
# tracking with mlflow
mlflow run text-in-image -P config=config/db_resnet50.yaml -P use_dist=False -P device=1

Multi gpu training:

# assume we have 2 gpu
python -m torch.distributed.launch --nnodes=1 --node_rank=0 --nproc_per_node=2 --master_addr= --master_post=5555 --config config/db_resnet50.yaml

Serve and Inference


Then, open your browser at Request url of the image, the result is as follows:


  • Multi gpu training
  • Tracking experiments with Mlflow
  • Model serving with FastAPI
  • Add more text detection and recognition model


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ultocr-0.3.1.tar.gz (43.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page