Skip to main content

Quickstart

pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
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 = Image.open('..')  # ..is the path of image
result = model.get_result(image)

Or view in google colab demo

Install

git clone https://github.com/cuongngm/text-in-image
pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt
bash scripts/download_weights.sh

Prepare data

Pretrained model

Model size(MB)
DB 140
MASTER 261

Train

Custom params in each config file of config folder then:

Single gpu training:

python train.py --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=127.0.0.1 --master_post=5555 train.py --config config/db_resnet50.yaml

Serve and Inference

python run.py

Then, open your browser at http://127.0.0.1:8000/docs. Request url of the image, the result is as follows:

Todo

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

Reference

Metadata

Release files for ultocr 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ultocr 0.3.1
File Size Uploaded
ultocr-0.3.1.tar.gz 43.4 kB Details

Release files / ultocr-0.3.1.tar.gz

Download URL ultocr-0.3.1.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5e19931fe841d5e0d5797dc7ba6decf0270462a8dc16ca6778c7d32806548c58
BLAKE2b-256 checksum
How to use checksums
3615043a5ce90f6faab5a24aba42f762dad1c018bf717f7f647ea4e8c1078f7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.51.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.12

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page