Optical Character Recognition (OCR) with OpenVINO

This tutorial demonstrates how to perform optical character recognition (OCR) with OpenVINO models. It is a continuation of the 004-hello-detection tutorial, which shows only text detection.

The horizontal-text-detection-0001 and text-recognition-resnet models are used together for text detection and then text recognition.

In this tutorial, Open Model Zoo tools including Model Downloader, Model Converter and Info Dumper are used to download and convert the models from the Open Model Zoo. See the 104-model-tools tutorial for more information about these tools.

Imports

import shutil
import sys
from pathlib import Path

import cv2
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Markdown, display
from PIL import Image
from openvino.runtime import Core
from yaspin import yaspin

sys.path.append("../utils")
from notebook_utils import load_image

Settings

ie = Core()

model_dir = Path("model")
precision = "FP16"
detection_model = "horizontal-text-detection-0001"
recognition_model = "text-recognition-resnet-fc"
base_model_dir = Path("~/open_model_zoo_models").expanduser()
omz_cache_dir = Path("~/open_model_zoo_cache").expanduser()

model_dir.mkdir(exist_ok=True)

Download Models

The next cells will run Open Model Zoo’s Model Downloader to download the detection and recognition models. If the models have been downloaded before, they will not be downloaded again.

download_command = f"omz_downloader --name {detection_model},{recognition_model} --output_dir {base_model_dir} --cache_dir {omz_cache_dir} --precision {precision}"
display(Markdown(f"Download command: `{download_command}`"))
with yaspin(text=f"Downloading {detection_model}, {recognition_model}") as sp:
    download_result = !$download_command
    print(download_result)
    sp.text = f"Finished downloading {detection_model}, {recognition_model}"
    sp.ok("✔")

Download command: omz_downloader --name horizontal-text-detection-0001,text-recognition-resnet-fc --output_dir /home/runner/open_model_zoo_models --cache_dir /home/runner/open_model_zoo_cache --precision FP16

⠏ Downloading horizontal-text-detection-0001, text-recognition-resnet-fc['################|| Downloading horizontal-text-detection-0001 ||################', '', '========== Downloading /home/runner/open_model_zoo_models/intel/horizontal-text-detection-0001/FP16/horizontal-text-detection-0001.xml', '... 100%, 956 KB, 2563 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/intel/horizontal-text-detection-0001/FP16/horizontal-text-detection-0001.bin', '... 27%, 1024 KB, 2711 KB/s, 0 seconds passed', '... 54%, 2048 KB, 4473 KB/s, 0 seconds passed', '... 81%, 3072 KB, 5850 KB/s, 0 seconds passed', '... 100%, 3786 KB, 7160 KB/s, 0 seconds passed', '', '################|| Downloading text-recognition-resnet-fc ||################', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/__init__.py', '... 100%, 0 KB, 100 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/builder.py', '... 100%, 0 KB, 597 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/model.py', '... 100%, 0 KB, 2086 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/weight_init.py', '... 100%, 3 KB, 10539 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/registry.py', '... 100%, 0 KB, 192 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/__init__.py', '... 100%, 0 KB, 610 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/builder.py', '... 100%, 0 KB, 604 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/fc_head.py', '... 100%, 1 KB, 5966 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/registry.py', '... 100%, 0 KB, 241 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/__init__.py', '... 100%, 0 KB, 1368 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/builder.py', '... 100%, 0 KB, 1063 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/registry.py', '... 100%, 0 KB, 340 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/body.py', '... 100%, 1 KB, 4043 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/component.py', '... 100%, 1 KB, 3768 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/__init__.py', '... 100%, 0 KB, 468 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/builder.py', '... 100%, 0 KB, 1363 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/registry.py', '... 100%, 0 KB, 425 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/__init__.py', '... 100%, 0 KB, 602 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/builder.py', '... 100%, 0 KB, 2286 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/__init__.py', '... 100%, 0 KB, 368 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/builder.py', '... 100%, 0 KB, 646 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/registry.py', '... 100%, 0 KB, 225 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/__init__.py', '... 100%, 0 KB, 514 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/bricks.py', '... 100%, 6 KB, 19883 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/builder.py', '... 100%, 0 KB, 1085 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/registry.py', '... 100%, 0 KB, 219 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/__init__.py', '... 100%, 0 KB, 394 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/builder.py', '... 100%, 0 KB, 1391 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/__init__.py', '... 100%, 0 KB, 303 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/builder.py', '... 100%, 0 KB, 638 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/registry.py', '... 100%, 0 KB, 224 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/resnet.py', '... 100%, 8 KB, 26187 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/__init__.py', '... 100%, 0 KB, 288 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/builder.py', '... 100%, 0 KB, 740 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/registry.py', '... 100%, 0 KB, 270 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/__init__.py', '... 100%, 0 KB, 692 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/builder.py', '... 100%, 0 KB, 1085 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/conv_module.py', '... 100%, 7 KB, 19480 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/fc_module.py', '... 100%, 2 KB, 8380 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/norm.py', '... 100%, 1 KB, 5302 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/registry.py', '... 100%, 0 KB, 203 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/__init__.py', '... 100%, 0 KB, 849 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/common.py', '... 100%, 3 KB, 10638 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/registry.py', '... 100%, 1 KB, 4151 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '... 100%, 5 KB, 15682 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/configs/resnet_fc.py', '... 100%, 8 KB, 23694 KB/s, 0 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/ckpt/resnet_fc.pth', '... 0%, 1024 KB, 2750 KB/s, 0 seconds passed', '... 0%, 2048 KB, 4581 KB/s, 0 seconds passed', '... 0%, 3072 KB, 5910 KB/s, 0 seconds passed', '... 0%, 4096 KB, 7822 KB/s, 0 seconds passed', '... 0%, 5120 KB, 8651 KB/s, 0 seconds passed', '... 0%, 6144 KB, 10280 KB/s, 0 seconds passed', '... 1%, 7168 KB, 11906 KB/s, 0 seconds passed', '... 1%, 8192 KB, 13490 KB/s, 0 seconds passed', '... 1%, 9216 KB, 15006 KB/s, 0 seconds passed', '... 1%, 10240 KB, 15363 KB/s, 0 seconds passed', '... 1%, 11264 KB, 16761 KB/s, 0 seconds passed', '... 1%, 12288 KB, 18164 KB/s, 0 seconds passed', '... 1%, 13312 KB, 19543 KB/s, 0 seconds passed', '... 2%, 14336 KB, 19344 KB/s, 0 seconds passed', '... 2%, 15360 KB, 20584 KB/s, 0 seconds passed', '... 2%, 16384 KB, 21843 KB/s, 0 seconds passed', '... 2%, 17408 KB, 22902 KB/s, 0 seconds passed', '... 2%, 18432 KB, 22651 KB/s, 0 seconds passed', '... 2%, 19456 KB, 23791 KB/s, 0 seconds passed', '... 2%, 20480 KB, 24932 KB/s, 0 seconds passed', '... 3%, 21504 KB, 25853 KB/s, 0 seconds passed', '... 3%, 22528 KB, 25445 KB/s, 0 seconds passed', '... 3%, 23552 KB, 26473 KB/s, 0 seconds passed', '... 3%, 24576 KB, 27498 KB/s, 0 seconds passed', '... 3%, 25600 KB, 28330 KB/s, 0 seconds passed', '... 3%, 26624 KB, 29341 KB/s, 0 seconds passed', '... 3%, 27648 KB, 28756 KB/s, 0 seconds passed', '... 4%, 28672 KB, 29688 KB/s, 0 seconds passed', '... 4%, 29696 KB, 30628 KB/s, 0 seconds passed', '... 4%, 30720 KB, 31355 KB/s, 0 seconds passed', '... 4%, 31744 KB, 32279 KB/s, 0 seconds passed', '... 4%, 32768 KB, 31624 KB/s, 1 seconds passed', '... 4%, 33792 KB, 32459 KB/s, 1 seconds passed', '... 5%, 34816 KB, 33239 KB/s, 1 seconds passed', '... 5%, 35840 KB, 34076 KB/s, 1 seconds passed', '... 5%, 36864 KB, 34749 KB/s, 1 seconds passed', '... 5%, 37888 KB, 33973 KB/s, 1 seconds passed', '... 5%, 38912 KB, 34513 KB/s, 1 seconds passed', '... 5%, 39936 KB, 35277 KB/s, 1 seconds passed', '... 5%, 40960 KB, 36027 KB/s, 1 seconds passed', '... 6%, 41984 KB, 35482 KB/s, 1 seconds passed', '... 6%, 43008 KB, 36199 KB/s, 1 seconds passed', '... 6%, 44032 KB, 36662 KB/s, 1 seconds passed', '... 6%, 45056 KB, 35852 KB/s, 1 seconds passed', '... 6%, 46080 KB, 36504 KB/s, 1 seconds passed', '... 6%, 47104 KB, 37170 KB/s, 1 seconds passed', '... 6%, 48128 KB, 37838 KB/s, 1 seconds passed', '... 7%, 49152 KB, 38393 KB/s, 1 seconds passed', '... 7%, 50176 KB, 37663 KB/s, 1 seconds passed', '... 7%, 51200 KB, 38296 KB/s, 1 seconds passed', '... 7%, 52224 KB, 38847 KB/s, 1 seconds passed', '... 7%, 53248 KB, 39432 KB/s, 1 seconds passed', '... 7%, 54272 KB, 38663 KB/s, 1 seconds passed', '... 7%, 55296 KB, 39274 KB/s, 1 seconds passed', '... 8%, 56320 KB, 39798 KB/s, 1 seconds passed', '... 8%, 57344 KB, 40333 KB/s, 1 seconds passed', '... 8%, 58368 KB, 40950 KB/s, 1 seconds passed', '... 8%, 59392 KB, 40121 KB/s, 1 seconds passed', '... 8%, 60416 KB, 40678 KB/s, 1 seconds passed', '... 8%, 61440 KB, 41048 KB/s, 1 seconds passed', '... 8%, 62464 KB, 41581 KB/s, 1 seconds passed', '... 9%, 63488 KB, 42129 KB/s, 1 seconds passed', '... 9%, 64512 KB, 41531 KB/s, 1 seconds passed', '... 9%, 65536 KB, 42074 KB/s, 1 seconds passed', '... 9%, 66560 KB, 41469 KB/s, 1 seconds passed', '... 9%, 67584 KB, 41962 KB/s, 1 seconds passed', '... 9%, 68608 KB, 42494 KB/s, 1 seconds passed', '... 10%, 69632 KB, 42791 KB/s, 1 seconds passed', '... 10%, 70656 KB, 43316 KB/s, 1 seconds passed', '... 10%, 71680 KB, 41139 KB/s, 1 seconds passed', '... 10%, 72704 KB, 41620 KB/s, 1 seconds passed', '... 10%, 73728 KB, 42105 KB/s, 1 seconds passed', '... 10%, 74752 KB, 42539 KB/s, 1 seconds passed', '... 10%, 75776 KB, 42960 KB/s, 1 seconds passed', '... 11%, 76800 KB, 41581 KB/s, 1 seconds passed', '... 11%, 77824 KB, 42008 KB/s, 1 seconds passed', '... 11%, 78848 KB, 42439 KB/s, 1 seconds passed', '... 11%, 79872 KB, 42869 KB/s, 1 seconds passed', '... 11%, 80896 KB, 43245 KB/s, 1 seconds passed', '... 11%, 81920 KB, 42382 KB/s, 1 seconds passed', '... 11%, 82944 KB, 42310 KB/s, 1 seconds passed', '... 12%, 83968 KB, 42647 KB/s, 1 seconds passed', '... 12%, 84992 KB, 43061 KB/s, 1 seconds passed', '... 12%, 86016 KB, 43485 KB/s, 1 seconds passed', '... 12%, 87040 KB, 42911 KB/s, 2 seconds passed', '... 12%, 88064 KB, 43116 KB/s, 2 seconds passed', '... 12%, 89088 KB, 43524 KB/s, 2 seconds passed', '... 12%, 90112 KB, 43904 KB/s, 2 seconds passed', '... 13%, 91136 KB, 44238 KB/s, 2 seconds passed', '... 13%, 92160 KB, 43005 KB/s, 2 seconds passed', '... 13%, 93184 KB, 43403 KB/s, 2 seconds passed', '... 13%, 94208 KB, 43785 KB/s, 2 seconds passed', '... 13%, 95232 KB, 44101 KB/s, 2 seconds passed', '... 13%, 96256 KB, 44489 KB/s, 2 seconds passed', '... 13%, 97280 KB, 43582 KB/s, 2 seconds passed', '... 14%, 98304 KB, 43955 KB/s, 2 seconds passed', '... 14%, 99328 KB, 44294 KB/s, 2 seconds passed', '... 14%, 100352 KB, 44653 KB/s, 2 seconds passed', '... 14%, 101376 KB, 44986 KB/s, 2 seconds passed', '... 14%, 102400 KB, 44325 KB/s, 2 seconds passed', '... 14%, 103424 KB, 44641 KB/s, 2 seconds passed', '... 15%, 104448 KB, 45000 KB/s, 2 seconds passed', '... 15%, 105472 KB, 45336 KB/s, 2 seconds passed', '... 15%, 106496 KB, 45617 KB/s, 2 seconds passed', '... 15%, 107520 KB, 44890 KB/s, 2 seconds passed', '... 15%, 108544 KB, 45216 KB/s, 2 seconds passed', '... 15%, 109568 KB, 45551 KB/s, 2 seconds passed', '... 15%, 110592 KB, 45777 KB/s, 2 seconds passed', '... 16%, 111616 KB, 46081 KB/s, 2 seconds passed', '... 16%, 112640 KB, 45073 KB/s, 2 seconds passed', '... 16%, 113664 KB, 45289 KB/s, 2 seconds passed', '... 16%, 114688 KB, 45588 KB/s, 2 seconds passed', '... 16%, 115712 KB, 45872 KB/s, 2 seconds passed', '... 16%, 116736 KB, 46178 KB/s, 2 seconds passed', '... 16%, 117760 KB, 45368 KB/s, 2 seconds passed', '... 17%, 118784 KB, 45688 KB/s, 2 seconds passed', '... 17%, 119808 KB, 45994 KB/s, 2 seconds passed', '... 17%, 120832 KB, 45543 KB/s, 2 seconds passed', '... 17%, 121856 KB, 45769 KB/s, 2 seconds passed', '... 17%, 122880 KB, 44061 KB/s, 2 seconds passed', '... 17%, 123904 KB, 44322 KB/s, 2 seconds passed', '... 17%, 124928 KB, 44631 KB/s, 2 seconds passed', '... 18%, 125952 KB, 44794 KB/s, 2 seconds passed', '... 18%, 126976 KB, 44995 KB/s, 2 seconds passed', '... 18%, 128000 KB, 44360 KB/s, 2 seconds passed', '... 18%, 129024 KB, 44563 KB/s, 2 seconds passed', '... 18%, 130048 KB, 44837 KB/s, 2 seconds passed', '... 18%, 131072 KB, 45074 KB/s, 2 seconds passed', '... 18%, 132096 KB, 45344 KB/s, 2 seconds passed', '... 19%, 133120 KB, 44516 KB/s, 2 seconds passed', '... 19%, 134144 KB, 44743 KB/s, 2 seconds passed', '... 19%, 135168 KB, 45031 KB/s, 3 seconds passed', '... 19%, 136192 KB, 45267 KB/s, 3 seconds passed', '... 19%, 137216 KB, 45500 KB/s, 3 seconds passed', '... 19%, 138240 KB, 43507 KB/s, 3 seconds passed', '... 20%, 139264 KB, 43748 KB/s, 3 seconds passed', '... 20%, 140288 KB, 43932 KB/s, 3 seconds passed', '... 20%, 141312 KB, 44189 KB/s, 3 seconds passed', '... 20%, 142336 KB, 44452 KB/s, 3 seconds passed', '... 20%, 143360 KB, 44059 KB/s, 3 seconds passed', '... 20%, 144384 KB, 44246 KB/s, 3 seconds passed', '... 20%, 145408 KB, 43646 KB/s, 3 seconds passed', '... 21%, 146432 KB, 43890 KB/s, 3 seconds passed', '... 21%, 147456 KB, 44145 KB/s, 3 seconds passed', '... 21%, 148480 KB, 43416 KB/s, 3 seconds passed', '... 21%, 149504 KB, 43643 KB/s, 3 seconds passed', '... 21%, 150528 KB, 43872 KB/s, 3 seconds passed', '... 21%, 151552 KB, 44069 KB/s, 3 seconds passed', '... 21%, 152576 KB, 44228 KB/s, 3 seconds passed', '... 22%, 153600 KB, 43670 KB/s, 3 seconds passed', '... 22%, 154624 KB, 43764 KB/s, 3 seconds passed', '... 22%, 155648 KB, 43997 KB/s, 3 seconds passed', '... 22%, 156672 KB, 44223 KB/s, 3 seconds passed', '... 22%, 157696 KB, 44163 KB/s, 3 seconds passed', '... 22%, 158720 KB, 43711 KB/s, 3 seconds passed', '... 22%, 159744 KB, 43702 KB/s, 3 seconds passed', '... 23%, 160768 KB, 43928 KB/s, 3 seconds passed', '... 23%, 161792 KB, 44165 KB/s, 3 seconds passed', '... 23%, 162816 KB, 44360 KB/s, 3 seconds passed', '... 23%, 163840 KB, 43885 KB/s, 3 seconds passed', '... 23%, 164864 KB, 44097 KB/s, 3 seconds passed', '... 23%, 165888 KB, 44320 KB/s, 3 seconds passed', '... 23%, 166912 KB, 44492 KB/s, 3 seconds passed', '... 24%, 167936 KB, 44712 KB/s, 3 seconds passed', '... 24%, 168960 KB, 44185 KB/s, 3 seconds passed', '... 24%, 169984 KB, 44379 KB/s, 3 seconds passed', '... 24%, 171008 KB, 44595 KB/s, 3 seconds passed', '... 24%, 172032 KB, 44777 KB/s, 3 seconds passed', '... 24%, 173056 KB, 44963 KB/s, 3 seconds passed', '... 25%, 174080 KB, 44652 KB/s, 3 seconds passed', '... 25%, 175104 KB, 44858 KB/s, 3 seconds passed', '... 25%, 176128 KB, 45070 KB/s, 3 seconds passed', '... 25%, 177152 KB, 45257 KB/s, 3 seconds passed', '... 25%, 178176 KB, 45342 KB/s, 3 seconds passed', '... 25%, 179200 KB, 44253 KB/s, 4 seconds passed', '... 25%, 180224 KB, 44444 KB/s, 4 seconds passed', '... 26%, 181248 KB, 44648 KB/s, 4 seconds passed', '... 26%, 182272 KB, 44842 KB/s, 4 seconds passed', '... 26%, 183296 KB, 45000 KB/s, 4 seconds passed', '... 26%, 184320 KB, 44588 KB/s, 4 seconds passed', '... 26%, 185344 KB, 44773 KB/s, 4 seconds passed', '... 26%, 186368 KB, 44933 KB/s, 4 seconds passed', '... 26%, 187392 KB, 45115 KB/s, 4 seconds passed', '... 27%, 188416 KB, 45286 KB/s, 4 seconds passed', '... 27%, 189440 KB, 44775 KB/s, 4 seconds passed', '... 27%, 190464 KB, 44888 KB/s, 4 seconds passed', '... 27%, 191488 KB, 45059 KB/s, 4 seconds passed', '... 27%, 192512 KB, 45234 KB/s, 4 seconds passed', '... 27%, 193536 KB, 45423 KB/s, 4 seconds passed', '... 27%, 194560 KB, 44944 KB/s, 4 seconds passed', '... 28%, 195584 KB, 45062 KB/s, 4 seconds passed', '... 28%, 196608 KB, 45194 KB/s, 4 seconds passed', '... 28%, 197632 KB, 45336 KB/s, 4 seconds passed', '... 28%, 198656 KB, 45422 KB/s, 4 seconds passed', '... 28%, 199680 KB, 45022 KB/s, 4 seconds passed', '... 28%, 200704 KB, 45190 KB/s, 4 seconds passed', '... 29%, 201728 KB, 44650 KB/s, 4 seconds passed', '... 29%, 202752 KB, 44668 KB/s, 4 seconds passed', '... 29%, 203776 KB, 44819 KB/s, 4 seconds passed', '... 29%, 204800 KB, 45000 KB/s, 4 seconds passed', '... 29%, 205824 KB, 45184 KB/s, 4 seconds passed', '... 29%, 206848 KB, 45320 KB/s, 4 seconds passed', '... 29%, 207872 KB, 45081 KB/s, 4 seconds passed', '... 30%, 208896 KB, 45253 KB/s, 4 seconds passed', '... 30%, 209920 KB, 45279 KB/s, 4 seconds passed', '... 30%, 210944 KB, 45463 KB/s, 4 seconds passed', '... 30%, 211968 KB, 45645 KB/s, 4 seconds passed', '... 30%, 212992 KB, 45431 KB/s, 4 seconds passed', '... 30%, 214016 KB, 45608 KB/s, 4 seconds passed', '... 30%, 215040 KB, 45418 KB/s, 4 seconds passed', '... 31%, 216064 KB, 45566 KB/s, 4 seconds passed', '... 31%, 217088 KB, 45707 KB/s, 4 seconds passed', '... 31%, 218112 KB, 45813 KB/s, 4 seconds passed', '... 31%, 219136 KB, 45947 KB/s, 4 seconds passed', '... 31%, 220160 KB, 45800 KB/s, 4 seconds passed', '... 31%, 221184 KB, 45944 KB/s, 4 seconds passed', '... 31%, 222208 KB, 45908 KB/s, 4 seconds passed', '... 32%, 223232 KB, 46070 KB/s, 4 seconds passed', '... 32%, 224256 KB, 46205 KB/s, 4 seconds passed', '... 32%, 225280 KB, 45871 KB/s, 4 seconds passed', '... 32%, 226304 KB, 46029 KB/s, 4 seconds passed', '... 32%, 227328 KB, 46138 KB/s, 4 seconds passed', '... 32%, 228352 KB, 46262 KB/s, 4 seconds passed', '... 32%, 229376 KB, 46295 KB/s, 4 seconds passed', '... 33%, 230400 KB, 45808 KB/s, 5 seconds passed', '... 33%, 231424 KB, 45933 KB/s, 5 seconds passed', '... 33%, 232448 KB, 46097 KB/s, 5 seconds passed', '... 33%, 233472 KB, 46268 KB/s, 5 seconds passed', '... 33%, 234496 KB, 46379 KB/s, 5 seconds passed', '... 33%, 235520 KB, 46056 KB/s, 5 seconds passed', '... 34%, 236544 KB, 46179 KB/s, 5 seconds passed', '... 34%, 237568 KB, 46329 KB/s, 5 seconds passed', '... 34%, 238592 KB, 46454 KB/s, 5 seconds passed', '... 34%, 239616 KB, 46610 KB/s, 5 seconds passed', '... 34%, 240640 KB, 46098 KB/s, 5 seconds passed', '... 34%, 241664 KB, 46260 KB/s, 5 seconds passed', '... 34%, 242688 KB, 46411 KB/s, 5 seconds passed', '... 35%, 243712 KB, 46553 KB/s, 5 seconds passed', '... 35%, 244736 KB, 46691 KB/s, 5 seconds passed', '... 35%, 245760 KB, 46124 KB/s, 5 seconds passed', '... 35%, 246784 KB, 46252 KB/s, 5 seconds passed', '... 35%, 247808 KB, 46403 KB/s, 5 seconds passed', '... 35%, 248832 KB, 46545 KB/s, 5 seconds passed', '... 35%, 249856 KB, 46701 KB/s, 5 seconds passed', '... 36%, 250880 KB, 46183 KB/s, 5 seconds passed', '... 36%, 251904 KB, 46252 KB/s, 5 seconds passed', '... 36%, 252928 KB, 46404 KB/s, 5 seconds passed', '... 36%, 253952 KB, 46409 KB/s, 5 seconds passed', '... 36%, 254976 KB, 46534 KB/s, 5 seconds passed', '... 36%, 256000 KB, 46013 KB/s, 5 seconds passed', '... 36%, 257024 KB, 46141 KB/s, 5 seconds passed', '... 37%, 258048 KB, 46295 KB/s, 5 seconds passed', '... 37%, 259072 KB, 46417 KB/s, 5 seconds passed', '... 37%, 260096 KB, 46537 KB/s, 5 seconds passed', '... 37%, 261120 KB, 46280 KB/s, 5 seconds passed', '... 37%, 262144 KB, 46305 KB/s, 5 seconds passed', '... 37%, 263168 KB, 46441 KB/s, 5 seconds passed', '... 37%, 264192 KB, 46557 KB/s, 5 seconds passed', '... 38%, 265216 KB, 46666 KB/s, 5 seconds passed', '... 38%, 266240 KB, 46103 KB/s, 5 seconds passed', '... 38%, 267264 KB, 46221 KB/s, 5 seconds passed', '... 38%, 268288 KB, 46229 KB/s, 5 seconds passed', '... 38%, 269312 KB, 46318 KB/s, 5 seconds passed', '... 38%, 270336 KB, 46421 KB/s, 5 seconds passed', '... 39%, 271360 KB, 46271 KB/s, 5 seconds passed', '... 39%, 272384 KB, 46385 KB/s, 5 seconds passed', '... 39%, 273408 KB, 46514 KB/s, 5 seconds passed', '... 39%, 274432 KB, 46486 KB/s, 5 seconds passed', '... 39%, 275456 KB, 46623 KB/s, 5 seconds passed', '... 39%, 276480 KB, 46353 KB/s, 5 seconds passed', '... 39%, 277504 KB, 46484 KB/s, 5 seconds passed', '... 40%, 278528 KB, 46611 KB/s, 5 seconds passed', '... 40%, 279552 KB, 46727 KB/s, 5 seconds passed', '... 40%, 280576 KB, 46757 KB/s, 6 seconds passed', '... 40%, 281600 KB, 46452 KB/s, 6 seconds passed', '... 40%, 282624 KB, 46544 KB/s, 6 seconds passed', '... 40%, 283648 KB, 46657 KB/s, 6 seconds passed', '... 40%, 284672 KB, 46768 KB/s, 6 seconds passed', '... 41%, 285696 KB, 46864 KB/s, 6 seconds passed', '... 41%, 286720 KB, 46720 KB/s, 6 seconds passed', '... 41%, 287744 KB, 46796 KB/s, 6 seconds passed', '... 41%, 288768 KB, 46914 KB/s, 6 seconds passed', '... 41%, 289792 KB, 47012 KB/s, 6 seconds passed', '... 41%, 290816 KB, 47012 KB/s, 6 seconds passed', '... 41%, 291840 KB, 46548 KB/s, 6 seconds passed', '... 42%, 292864 KB, 46677 KB/s, 6 seconds passed', '... 42%, 293888 KB, 46810 KB/s, 6 seconds passed', '... 42%, 294912 KB, 46928 KB/s, 6 seconds passed', '... 42%, 295936 KB, 47042 KB/s, 6 seconds passed', '... 42%, 296960 KB, 46817 KB/s, 6 seconds passed', '... 42%, 297984 KB, 46945 KB/s, 6 seconds passed', '... 42%, 299008 KB, 47071 KB/s, 6 seconds passed', '... 43%, 300032 KB, 47191 KB/s, 6 seconds passed', '... 43%, 301056 KB, 47296 KB/s, 6 seconds passed', '... 43%, 302080 KB, 46944 KB/s, 6 seconds passed', '... 43%, 303104 KB, 47063 KB/s, 6 seconds passed', '... 43%, 304128 KB, 47159 KB/s, 6 seconds passed', '... 43%, 305152 KB, 47276 KB/s, 6 seconds passed', '... 44%, 306176 KB, 47403 KB/s, 6 seconds passed', '... 44%, 307200 KB, 47146 KB/s, 6 seconds passed', '... 44%, 308224 KB, 47272 KB/s, 6 seconds passed', '... 44%, 309248 KB, 47377 KB/s, 6 seconds passed', '... 44%, 310272 KB, 47460 KB/s, 6 seconds passed', '... 44%, 311296 KB, 47578 KB/s, 6 seconds passed', '... 44%, 312320 KB, 47034 KB/s, 6 seconds passed', '... 45%, 313344 KB, 47149 KB/s, 6 seconds passed', '... 45%, 314368 KB, 47274 KB/s, 6 seconds passed', '... 45%, 315392 KB, 47390 KB/s, 6 seconds passed', '... 45%, 316416 KB, 47486 KB/s, 6 seconds passed', '... 45%, 317440 KB, 47060 KB/s, 6 seconds passed', '... 45%, 318464 KB, 47091 KB/s, 6 seconds passed', '... 45%, 319488 KB, 47217 KB/s, 6 seconds passed', '... 46%, 320512 KB, 47344 KB/s, 6 seconds passed', '... 46%, 321536 KB, 47443 KB/s, 6 seconds passed', '... 46%, 322560 KB, 46929 KB/s, 6 seconds passed', '... 46%, 323584 KB, 46937 KB/s, 6 seconds passed', '... 46%, 324608 KB, 47040 KB/s, 6 seconds passed', '... 46%, 325632 KB, 47164 KB/s, 6 seconds passed', '... 46%, 326656 KB, 47277 KB/s, 6 seconds passed', '... 47%, 327680 KB, 47048 KB/s, 6 seconds passed', '... 47%, 328704 KB, 47156 KB/s, 6 seconds passed', '... 47%, 329728 KB, 47263 KB/s, 6 seconds passed', '... 47%, 330752 KB, 47364 KB/s, 6 seconds passed', '... 47%, 331776 KB, 47474 KB/s, 6 seconds passed', '... 47%, 332800 KB, 47257 KB/s, 7 seconds passed', '... 47%, 333824 KB, 47357 KB/s, 7 seconds passed', '... 48%, 334848 KB, 47467 KB/s, 7 seconds passed', '... 48%, 335872 KB, 47574 KB/s, 7 seconds passed', '... 48%, 336896 KB, 47665 KB/s, 7 seconds passed', '... 48%, 337920 KB, 47393 KB/s, 7 seconds passed', '... 48%, 338944 KB, 47498 KB/s, 7 seconds passed', '... 48%, 339968 KB, 47592 KB/s, 7 seconds passed', '... 49%, 340992 KB, 47705 KB/s, 7 seconds passed', '... 49%, 342016 KB, 47795 KB/s, 7 seconds passed', '... 49%, 343040 KB, 47490 KB/s, 7 seconds passed', '... 49%, 344064 KB, 47031 KB/s, 7 seconds passed', '... 49%, 345088 KB, 47138 KB/s, 7 seconds passed', '... 49%, 346112 KB, 47251 KB/s, 7 seconds passed', '... 49%, 347136 KB, 47356 KB/s, 7 seconds passed', '... 50%, 348160 KB, 47161 KB/s, 7 seconds passed', '... 50%, 349184 KB, 47247 KB/s, 7 seconds passed', '... 50%, 350208 KB, 47359 KB/s, 7 seconds passed', '... 50%, 351232 KB, 47467 KB/s, 7 seconds passed', '... 50%, 352256 KB, 47555 KB/s, 7 seconds passed', '... 50%, 353280 KB, 46814 KB/s, 7 seconds passed', '... 50%, 354304 KB, 46818 KB/s, 7 seconds passed', '... 51%, 355328 KB, 46907 KB/s, 7 seconds passed', '... 51%, 356352 KB, 47016 KB/s, 7 seconds passed', '... 51%, 357376 KB, 47102 KB/s, 7 seconds passed', '... 51%, 358400 KB, 47024 KB/s, 7 seconds passed', '... 51%, 359424 KB, 47097 KB/s, 7 seconds passed', '... 51%, 360448 KB, 47171 KB/s, 7 seconds passed', '... 51%, 361472 KB, 47213 KB/s, 7 seconds passed', '... 52%, 362496 KB, 47320 KB/s, 7 seconds passed', '... 52%, 363520 KB, 47130 KB/s, 7 seconds passed', '... 52%, 364544 KB, 47230 KB/s, 7 seconds passed', '... 52%, 365568 KB, 47334 KB/s, 7 seconds passed', '... 52%, 366592 KB, 47411 KB/s, 7 seconds passed', '... 52%, 367616 KB, 47519 KB/s, 7 seconds passed', '... 53%, 368640 KB, 47240 KB/s, 7 seconds passed', '... 53%, 369664 KB, 47342 KB/s, 7 seconds passed', '... 53%, 370688 KB, 47442 KB/s, 7 seconds passed', '... 53%, 371712 KB, 47537 KB/s, 7 seconds passed', '... 53%, 372736 KB, 47637 KB/s, 7 seconds passed', '... 53%, 373760 KB, 47408 KB/s, 7 seconds passed', '... 53%, 374784 KB, 47428 KB/s, 7 seconds passed', '... 54%, 375808 KB, 47530 KB/s, 7 seconds passed', '... 54%, 376832 KB, 47636 KB/s, 7 seconds passed', '... 54%, 377856 KB, 47727 KB/s, 7 seconds passed', '... 54%, 378880 KB, 47216 KB/s, 8 seconds passed', '... 54%, 379904 KB, 47318 KB/s, 8 seconds passed', '... 54%, 380928 KB, 47422 KB/s, 8 seconds passed', '... 54%, 381952 KB, 47471 KB/s, 8 seconds passed', '... 55%, 382976 KB, 47553 KB/s, 8 seconds passed', '... 55%, 384000 KB, 47272 KB/s, 8 seconds passed', '... 55%, 385024 KB, 47370 KB/s, 8 seconds passed', '... 55%, 386048 KB, 47438 KB/s, 8 seconds passed', '... 55%, 387072 KB, 47528 KB/s, 8 seconds passed', '... 55%, 388096 KB, 47622 KB/s, 8 seconds passed', '... 55%, 389120 KB, 47455 KB/s, 8 seconds passed', '... 56%, 390144 KB, 47537 KB/s, 8 seconds passed', '... 56%, 391168 KB, 47632 KB/s, 8 seconds passed', '... 56%, 392192 KB, 47563 KB/s, 8 seconds passed', '... 56%, 393216 KB, 47662 KB/s, 8 seconds passed', '... 56%, 394240 KB, 47550 KB/s, 8 seconds passed', '... 56%, 395264 KB, 47645 KB/s, 8 seconds passed', '... 56%, 396288 KB, 47702 KB/s, 8 seconds passed', '... 57%, 397312 KB, 47747 KB/s, 8 seconds passed', '... 57%, 398336 KB, 47724 KB/s, 8 seconds passed', '... 57%, 399360 KB, 47735 KB/s, 8 seconds passed', '... 57%, 400384 KB, 47802 KB/s, 8 seconds passed', '... 57%, 401408 KB, 47895 KB/s, 8 seconds passed', '... 57%, 402432 KB, 47937 KB/s, 8 seconds passed', '... 58%, 403456 KB, 47912 KB/s, 8 seconds passed', '... 58%, 404480 KB, 47704 KB/s, 8 seconds passed', '... 58%, 405504 KB, 47784 KB/s, 8 seconds passed', '... 58%, 406528 KB, 47884 KB/s, 8 seconds passed', '... 58%, 407552 KB, 47984 KB/s, 8 seconds passed', '... 58%, 408576 KB, 48045 KB/s, 8 seconds passed', '... 58%, 409600 KB, 47889 KB/s, 8 seconds passed', '... 59%, 410624 KB, 47960 KB/s, 8 seconds passed', '... 59%, 411648 KB, 48050 KB/s, 8 seconds passed', '... 59%, 412672 KB, 48122 KB/s, 8 seconds passed', '... 59%, 413696 KB, 48219 KB/s, 8 seconds passed', '... 59%, 414720 KB, 47706 KB/s, 8 seconds passed', '... 59%, 415744 KB, 47793 KB/s, 8 seconds passed', '... 59%, 416768 KB, 47887 KB/s, 8 seconds passed', '... 60%, 417792 KB, 47951 KB/s, 8 seconds passed', '... 60%, 418816 KB, 48037 KB/s, 8 seconds passed', '... 60%, 419840 KB, 47792 KB/s, 8 seconds passed', '... 60%, 420864 KB, 47874 KB/s, 8 seconds passed', '... 60%, 421888 KB, 47946 KB/s, 8 seconds passed', '... 60%, 422912 KB, 48032 KB/s, 8 seconds passed', '... 60%, 423936 KB, 48129 KB/s, 8 seconds passed', '... 61%, 424960 KB, 47969 KB/s, 8 seconds passed', '... 61%, 425984 KB, 48062 KB/s, 8 seconds passed', '... 61%, 427008 KB, 48147 KB/s, 8 seconds passed', '... 61%, 428032 KB, 48201 KB/s, 8 seconds passed', '... 61%, 429056 KB, 48297 KB/s, 8 seconds passed', '... 61%, 430080 KB, 48146 KB/s, 8 seconds passed', '... 61%, 431104 KB, 48226 KB/s, 8 seconds passed', '... 62%, 432128 KB, 48316 KB/s, 8 seconds passed', '... 62%, 433152 KB, 48366 KB/s, 8 seconds passed', '... 62%, 434176 KB, 48294 KB/s, 8 seconds passed', '... 62%, 435200 KB, 48227 KB/s, 9 seconds passed', '... 62%, 436224 KB, 48272 KB/s, 9 seconds passed', '... 62%, 437248 KB, 48362 KB/s, 9 seconds passed', '... 63%, 438272 KB, 48446 KB/s, 9 seconds passed', '... 63%, 439296 KB, 48463 KB/s, 9 seconds passed', '... 63%, 440320 KB, 48289 KB/s, 9 seconds passed', '... 63%, 441344 KB, 48377 KB/s, 9 seconds passed', '... 63%, 442368 KB, 48467 KB/s, 9 seconds passed', '... 63%, 443392 KB, 48539 KB/s, 9 seconds passed', '... 63%, 444416 KB, 48619 KB/s, 9 seconds passed', '... 64%, 445440 KB, 48406 KB/s, 9 seconds passed', '... 64%, 446464 KB, 48487 KB/s, 9 seconds passed', '... 64%, 447488 KB, 48572 KB/s, 9 seconds passed', '... 64%, 448512 KB, 48661 KB/s, 9 seconds passed', '... 64%, 449536 KB, 48727 KB/s, 9 seconds passed', '... 64%, 450560 KB, 48470 KB/s, 9 seconds passed', '... 64%, 451584 KB, 48545 KB/s, 9 seconds passed', '... 65%, 452608 KB, 48620 KB/s, 9 seconds passed', '... 65%, 453632 KB, 48701 KB/s, 9 seconds passed', '... 65%, 454656 KB, 48763 KB/s, 9 seconds passed', '... 65%, 455680 KB, 48624 KB/s, 9 seconds passed', '... 65%, 456704 KB, 48676 KB/s, 9 seconds passed', '... 65%, 457728 KB, 48748 KB/s, 9 seconds passed', '... 65%, 458752 KB, 48834 KB/s, 9 seconds passed', '... 66%, 459776 KB, 48919 KB/s, 9 seconds passed', '... 66%, 460800 KB, 48605 KB/s, 9 seconds passed', '... 66%, 461824 KB, 48591 KB/s, 9 seconds passed', '... 66%, 462848 KB, 48666 KB/s, 9 seconds passed', '... 66%, 463872 KB, 48744 KB/s, 9 seconds passed', '... 66%, 464896 KB, 48822 KB/s, 9 seconds passed', '... 66%, 465920 KB, 48341 KB/s, 9 seconds passed', '... 67%, 466944 KB, 48411 KB/s, 9 seconds passed', '... 67%, 467968 KB, 48496 KB/s, 9 seconds passed', '... 67%, 468992 KB, 48563 KB/s, 9 seconds passed', '... 67%, 470016 KB, 48638 KB/s, 9 seconds passed', '... 67%, 471040 KB, 48119 KB/s, 9 seconds passed', '... 67%, 472064 KB, 48195 KB/s, 9 seconds passed', '... 68%, 473088 KB, 48276 KB/s, 9 seconds passed', '... 68%, 474112 KB, 48362 KB/s, 9 seconds passed', '... 68%, 475136 KB, 48428 KB/s, 9 seconds passed', '... 68%, 476160 KB, 48279 KB/s, 9 seconds passed', '... 68%, 477184 KB, 48350 KB/s, 9 seconds passed', '... 68%, 478208 KB, 48431 KB/s, 9 seconds passed', '... 68%, 479232 KB, 48509 KB/s, 9 seconds passed', '... 69%, 480256 KB, 48571 KB/s, 9 seconds passed', '... 69%, 481280 KB, 48256 KB/s, 9 seconds passed', '... 69%, 482304 KB, 48322 KB/s, 9 seconds passed', '... 69%, 483328 KB, 48401 KB/s, 9 seconds passed', '... 69%, 484352 KB, 48485 KB/s, 9 seconds passed', '... 69%, 485376 KB, 48539 KB/s, 9 seconds passed', '... 69%, 486400 KB, 47943 KB/s, 10 seconds passed', '... 70%, 487424 KB, 47992 KB/s, 10 seconds passed', '... 70%, 488448 KB, 48072 KB/s, 10 seconds passed', '... 70%, 489472 KB, 48153 KB/s, 10 seconds passed', '... 70%, 490496 KB, 48207 KB/s, 10 seconds passed', '... 70%, 491520 KB, 47983 KB/s, 10 seconds passed', '... 70%, 492544 KB, 48053 KB/s, 10 seconds passed', '... 70%, 493568 KB, 48115 KB/s, 10 seconds passed', '... 71%, 494592 KB, 48195 KB/s, 10 seconds passed', '... 71%, 495616 KB, 48269 KB/s, 10 seconds passed', '... 71%, 496640 KB, 47947 KB/s, 10 seconds passed', '... 71%, 497664 KB, 48024 KB/s, 10 seconds passed', '... 71%, 498688 KB, 48094 KB/s, 10 seconds passed', '... 71%, 499712 KB, 48169 KB/s, 10 seconds passed', '... 71%, 500736 KB, 48240 KB/s, 10 seconds passed', '... 72%, 501760 KB, 48092 KB/s, 10 seconds passed', '... 72%, 502784 KB, 48152 KB/s, 10 seconds passed', '... 72%, 503808 KB, 48193 KB/s, 10 seconds passed', '... 72%, 504832 KB, 48266 KB/s, 10 seconds passed', '... 72%, 505856 KB, 48343 KB/s, 10 seconds passed', '... 72%, 506880 KB, 48184 KB/s, 10 seconds passed', '... 73%, 507904 KB, 48259 KB/s, 10 seconds passed', '... 73%, 508928 KB, 48337 KB/s, 10 seconds passed', '... 73%, 509952 KB, 48407 KB/s, 10 seconds passed', '... 73%, 510976 KB, 48470 KB/s, 10 seconds passed', '... 73%, 512000 KB, 48174 KB/s, 10 seconds passed', '... 73%, 513024 KB, 48230 KB/s, 10 seconds passed', '... 73%, 514048 KB, 48305 KB/s, 10 seconds passed', '... 74%, 515072 KB, 48367 KB/s, 10 seconds passed', '... 74%, 516096 KB, 48444 KB/s, 10 seconds passed', '... 74%, 517120 KB, 48233 KB/s, 10 seconds passed', '... 74%, 518144 KB, 48282 KB/s, 10 seconds passed', '... 74%, 519168 KB, 48356 KB/s, 10 seconds passed', '... 74%, 520192 KB, 48434 KB/s, 10 seconds passed', '... 74%, 521216 KB, 48483 KB/s, 10 seconds passed', '... 75%, 522240 KB, 48300 KB/s, 10 seconds passed', '... 75%, 523264 KB, 48344 KB/s, 10 seconds passed', '... 75%, 524288 KB, 48375 KB/s, 10 seconds passed', '... 75%, 525312 KB, 48442 KB/s, 10 seconds passed', '... 75%, 526336 KB, 48508 KB/s, 10 seconds passed', '... 75%, 527360 KB, 48041 KB/s, 10 seconds passed', '... 75%, 528384 KB, 48085 KB/s, 10 seconds passed', '... 76%, 529408 KB, 48156 KB/s, 10 seconds passed', '... 76%, 530432 KB, 48213 KB/s, 11 seconds passed', '... 76%, 531456 KB, 48288 KB/s, 11 seconds passed', '... 76%, 532480 KB, 48070 KB/s, 11 seconds passed', '... 76%, 533504 KB, 47980 KB/s, 11 seconds passed', '... 76%, 534528 KB, 48046 KB/s, 11 seconds passed', '... 77%, 535552 KB, 48116 KB/s, 11 seconds passed', '... 77%, 536576 KB, 48181 KB/s, 11 seconds passed', '... 77%, 537600 KB, 47894 KB/s, 11 seconds passed', '... 77%, 538624 KB, 47964 KB/s, 11 seconds passed', '... 77%, 539648 KB, 48026 KB/s, 11 seconds passed', '... 77%, 540672 KB, 48100 KB/s, 11 seconds passed', '... 77%, 541696 KB, 48162 KB/s, 11 seconds passed', '... 78%, 542720 KB, 47932 KB/s, 11 seconds passed', '... 78%, 543744 KB, 47999 KB/s, 11 seconds passed', '... 78%, 544768 KB, 48061 KB/s, 11 seconds passed', '... 78%, 545792 KB, 48123 KB/s, 11 seconds passed', '... 78%, 546816 KB, 48196 KB/s, 11 seconds passed', '... 78%, 547840 KB, 47902 KB/s, 11 seconds passed', '... 78%, 548864 KB, 47919 KB/s, 11 seconds passed', '... 79%, 549888 KB, 47983 KB/s, 11 seconds passed', '... 79%, 550912 KB, 48048 KB/s, 11 seconds passed', '... 79%, 551936 KB, 48093 KB/s, 11 seconds passed', '... 79%, 552960 KB, 47878 KB/s, 11 seconds passed', '... 79%, 553984 KB, 47909 KB/s, 11 seconds passed', '... 79%, 555008 KB, 47962 KB/s, 11 seconds passed', '... 79%, 556032 KB, 48026 KB/s, 11 seconds passed', '... 80%, 557056 KB, 48098 KB/s, 11 seconds passed', '... 80%, 558080 KB, 47755 KB/s, 11 seconds passed', '... 80%, 559104 KB, 47708 KB/s, 11 seconds passed', '... 80%, 560128 KB, 47755 KB/s, 11 seconds passed', '... 80%, 561152 KB, 47824 KB/s, 11 seconds passed', '... 80%, 562176 KB, 47894 KB/s, 11 seconds passed', '... 80%, 563200 KB, 47661 KB/s, 11 seconds passed', '... 81%, 564224 KB, 47717 KB/s, 11 seconds passed', '... 81%, 565248 KB, 47778 KB/s, 11 seconds passed', '... 81%, 566272 KB, 47837 KB/s, 11 seconds passed', '... 81%, 567296 KB, 47873 KB/s, 11 seconds passed', '... 81%, 568320 KB, 47551 KB/s, 11 seconds passed', '... 81%, 569344 KB, 47610 KB/s, 11 seconds passed', '... 82%, 570368 KB, 47674 KB/s, 11 seconds passed', '... 82%, 571392 KB, 47732 KB/s, 11 seconds passed', '... 82%, 572416 KB, 47770 KB/s, 11 seconds passed', '... 82%, 573440 KB, 47375 KB/s, 12 seconds passed', '... 82%, 574464 KB, 47419 KB/s, 12 seconds passed', '... 82%, 575488 KB, 47487 KB/s, 12 seconds passed', '... 82%, 576512 KB, 47556 KB/s, 12 seconds passed', '... 83%, 577536 KB, 47603 KB/s, 12 seconds passed', '... 83%, 578560 KB, 47217 KB/s, 12 seconds passed', '... 83%, 579584 KB, 47280 KB/s, 12 seconds passed', '... 83%, 580608 KB, 47342 KB/s, 12 seconds passed', '... 83%, 581632 KB, 47404 KB/s, 12 seconds passed', '... 83%, 582656 KB, 47462 KB/s, 12 seconds passed', '... 83%, 583680 KB, 47242 KB/s, 12 seconds passed', '... 84%, 584704 KB, 47292 KB/s, 12 seconds passed', '... 84%, 585728 KB, 47354 KB/s, 12 seconds passed', '... 84%, 586752 KB, 47418 KB/s, 12 seconds passed', '... 84%, 587776 KB, 47472 KB/s, 12 seconds passed', '... 84%, 588800 KB, 47175 KB/s, 12 seconds passed', '... 84%, 589824 KB, 47173 KB/s, 12 seconds passed', '... 84%, 590848 KB, 47230 KB/s, 12 seconds passed', '... 85%, 591872 KB, 47272 KB/s, 12 seconds passed', '... 85%, 592896 KB, 47331 KB/s, 12 seconds passed', '... 85%, 593920 KB, 47155 KB/s, 12 seconds passed', '... 85%, 594944 KB, 47211 KB/s, 12 seconds passed', '... 85%, 595968 KB, 47275 KB/s, 12 seconds passed', '... 85%, 596992 KB, 47339 KB/s, 12 seconds passed', '... 85%, 598016 KB, 47385 KB/s, 12 seconds passed', '... 86%, 599040 KB, 47129 KB/s, 12 seconds passed', '... 86%, 600064 KB, 47150 KB/s, 12 seconds passed', '... 86%, 601088 KB, 47203 KB/s, 12 seconds passed', '... 86%, 602112 KB, 47261 KB/s, 12 seconds passed', '... 86%, 603136 KB, 47319 KB/s, 12 seconds passed', '... 86%, 604160 KB, 47066 KB/s, 12 seconds passed', '... 87%, 605184 KB, 47000 KB/s, 12 seconds passed', '... 87%, 606208 KB, 47059 KB/s, 12 seconds passed', '... 87%, 607232 KB, 46913 KB/s, 12 seconds passed', '... 87%, 608256 KB, 46975 KB/s, 12 seconds passed', '... 87%, 609280 KB, 46815 KB/s, 13 seconds passed', '... 87%, 610304 KB, 46871 KB/s, 13 seconds passed', '... 87%, 611328 KB, 46934 KB/s, 13 seconds passed', '... 88%, 612352 KB, 46996 KB/s, 13 seconds passed', '... 88%, 613376 KB, 47054 KB/s, 13 seconds passed', '... 88%, 614400 KB, 46681 KB/s, 13 seconds passed', '... 88%, 615424 KB, 46731 KB/s, 13 seconds passed', '... 88%, 616448 KB, 46793 KB/s, 13 seconds passed', '... 88%, 617472 KB, 46848 KB/s, 13 seconds passed', '... 88%, 618496 KB, 46898 KB/s, 13 seconds passed', '... 89%, 619520 KB, 46706 KB/s, 13 seconds passed', '... 89%, 620544 KB, 46694 KB/s, 13 seconds passed', '... 89%, 621568 KB, 46742 KB/s, 13 seconds passed', '... 89%, 622592 KB, 46791 KB/s, 13 seconds passed', '... 89%, 623616 KB, 46849 KB/s, 13 seconds passed', '... 89%, 624640 KB, 46413 KB/s, 13 seconds passed', '... 89%, 625664 KB, 46462 KB/s, 13 seconds passed', '... 90%, 626688 KB, 46501 KB/s, 13 seconds passed', '... 90%, 627712 KB, 46559 KB/s, 13 seconds passed', '... 90%, 628736 KB, 46621 KB/s, 13 seconds passed', '... 90%, 629760 KB, 46220 KB/s, 13 seconds passed', '... 90%, 630784 KB, 46278 KB/s, 13 seconds passed', '... 90%, 631808 KB, 46338 KB/s, 13 seconds passed', '... 90%, 632832 KB, 46382 KB/s, 13 seconds passed', '... 91%, 633856 KB, 46442 KB/s, 13 seconds passed', '... 91%, 634880 KB, 46360 KB/s, 13 seconds passed', '... 91%, 635904 KB, 46412 KB/s, 13 seconds passed', '... 91%, 636928 KB, 46469 KB/s, 13 seconds passed', '... 91%, 637952 KB, 46514 KB/s, 13 seconds passed', '... 91%, 638976 KB, 46567 KB/s, 13 seconds passed', '... 92%, 640000 KB, 46212 KB/s, 13 seconds passed', '... 92%, 641024 KB, 46084 KB/s, 13 seconds passed', '... 92%, 642048 KB, 46143 KB/s, 13 seconds passed', '... 92%, 643072 KB, 46202 KB/s, 13 seconds passed', '... 92%, 644096 KB, 46252 KB/s, 13 seconds passed', '... 92%, 645120 KB, 46148 KB/s, 13 seconds passed', '... 92%, 646144 KB, 46182 KB/s, 13 seconds passed', '... 93%, 647168 KB, 46237 KB/s, 13 seconds passed', '... 93%, 648192 KB, 46294 KB/s, 14 seconds passed', '... 93%, 649216 KB, 46353 KB/s, 14 seconds passed', '... 93%, 650240 KB, 46194 KB/s, 14 seconds passed', '... 93%, 651264 KB, 46236 KB/s, 14 seconds passed', '... 93%, 652288 KB, 46296 KB/s, 14 seconds passed', '... 93%, 653312 KB, 46347 KB/s, 14 seconds passed', '... 94%, 654336 KB, 46401 KB/s, 14 seconds passed', '... 94%, 655360 KB, 46252 KB/s, 14 seconds passed', '... 94%, 656384 KB, 46299 KB/s, 14 seconds passed', '... 94%, 657408 KB, 46325 KB/s, 14 seconds passed', '... 94%, 658432 KB, 46385 KB/s, 14 seconds passed', '... 94%, 659456 KB, 46446 KB/s, 14 seconds passed', '... 94%, 660480 KB, 46363 KB/s, 14 seconds passed', '... 95%, 661504 KB, 46399 KB/s, 14 seconds passed', '... 95%, 662528 KB, 46433 KB/s, 14 seconds passed', '... 95%, 663552 KB, 46481 KB/s, 14 seconds passed', '... 95%, 664576 KB, 46516 KB/s, 14 seconds passed', '... 95%, 665600 KB, 46430 KB/s, 14 seconds passed', '... 95%, 666624 KB, 46470 KB/s, 14 seconds passed', '... 95%, 667648 KB, 46517 KB/s, 14 seconds passed', '... 96%, 668672 KB, 46516 KB/s, 14 seconds passed', '... 96%, 669696 KB, 46553 KB/s, 14 seconds passed', '... 96%, 670720 KB, 46411 KB/s, 14 seconds passed', '... 96%, 671744 KB, 46426 KB/s, 14 seconds passed', '... 96%, 672768 KB, 46460 KB/s, 14 seconds passed', '... 96%, 673792 KB, 46502 KB/s, 14 seconds passed', '... 97%, 674816 KB, 46526 KB/s, 14 seconds passed', '... 97%, 675840 KB, 46374 KB/s, 14 seconds passed', '... 97%, 676864 KB, 46368 KB/s, 14 seconds passed', '... 97%, 677888 KB, 46407 KB/s, 14 seconds passed', '... 97%, 678912 KB, 46465 KB/s, 14 seconds passed', '... 97%, 679936 KB, 46494 KB/s, 14 seconds passed', '... 97%, 680960 KB, 45580 KB/s, 14 seconds passed', '... 98%, 681984 KB, 45619 KB/s, 14 seconds passed', '... 98%, 683008 KB, 45657 KB/s, 14 seconds passed', '... 98%, 684032 KB, 45161 KB/s, 15 seconds passed', '... 98%, 685056 KB, 45163 KB/s, 15 seconds passed', '... 98%, 686080 KB, 45207 KB/s, 15 seconds passed', '... 98%, 687104 KB, 45234 KB/s, 15 seconds passed', '... 98%, 688128 KB, 45254 KB/s, 15 seconds passed', '... 99%, 689152 KB, 45276 KB/s, 15 seconds passed', '... 99%, 690176 KB, 45267 KB/s, 15 seconds passed', '... 99%, 691200 KB, 45262 KB/s, 15 seconds passed', '... 99%, 692224 KB, 45092 KB/s, 15 seconds passed', '... 99%, 693248 KB, 45087 KB/s, 15 seconds passed', '... 99%, 694272 KB, 45128 KB/s, 15 seconds passed', '... 99%, 695296 KB, 45179 KB/s, 15 seconds passed', '... 100%, 695506 KB, 45183 KB/s, 15 seconds passed', '', '========== Downloading /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/addict-2.4.0-py3-none-any.whl', '... 100%, 3 KB, 5257 KB/s, 0 seconds passed', '', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/component.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/__init__.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Unpacking /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/addict-2.4.0-py3-none-any.whl', '']
✔ Finished downloading horizontal-text-detection-0001, text-recognition-resnet-fc
### The text-recognition-resnet-fc model consists of many files. All filenames are printed in
### Model Downloader's output. Uncomment the next two lines to show this output

# for line in download_result:
#    print(line)

Convert Models

The downloaded detection model is an Intel model, which is already in OpenVINO’s Intermediate Representation (IR) format. The text recognition model is a public model which needs to be converted to IR. Since this model was downloaded from Open Model Zoo we can use Model Converter to convert the model to IR format.

Model Converter output will be displayed. Conversion was succesful if the last lines of output include [ SUCCESS ] Generated IR version 11 model.

convert_command = f"omz_converter --name {recognition_model} --precisions {precision} --download_dir {base_model_dir} --output_dir {base_model_dir}"
display(Markdown(f"Convert command: `{convert_command}`"))
display(Markdown(f"Converting {recognition_model}..."))
! $convert_command

Convert command: omz_converter --name text-recognition-resnet-fc --precisions FP16 --download_dir /home/runner/open_model_zoo_models --output_dir /home/runner/open_model_zoo_models

Converting text-recognition-resnet-fc…

========== Converting text-recognition-resnet-fc to ONNX
Conversion to ONNX command: /opt/hostedtoolcache/Python/3.8.12/x64/bin/python -- /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/openvino/model_zoo/internal_scripts/pytorch_to_onnx.py --model-path=/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/openvino/model_zoo/models/public/text-recognition-resnet-fc --model-path=/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc --model-name=get_model --import-module=model '--model-param=file_config=r"/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/configs/resnet_fc.py"' '--model-param=weights=r"/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/ckpt/resnet_fc.pth"' --input-shape=1,1,32,100 --input-names=input --output-names=output --output-file=/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/resnet_fc.onnx

ONNX check passed successfully.

========== Converting text-recognition-resnet-fc to IR (FP16)
Conversion command: /opt/hostedtoolcache/Python/3.8.12/x64/bin/python -- /opt/hostedtoolcache/Python/3.8.12/x64/bin/mo --framework=onnx --data_type=FP16 --output_dir=/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/FP16 --model_name=text-recognition-resnet-fc --input=input '--mean_values=input[127.5]' '--scale_values=input[127.5]' --output=output --input_model=/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/resnet_fc.onnx '--layout=input(NCHW)' '--input_shape=[1, 1, 32, 100]'

Model Optimizer arguments:
Common parameters:
    - Path to the Input Model:  /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/resnet_fc.onnx
    - Path for generated IR:    /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/FP16
    - IR output name:   text-recognition-resnet-fc
    - Log level:    ERROR
    - Batch:    Not specified, inherited from the model
    - Input layers:     input
    - Output layers:    output
    - Input shapes:     [1, 1, 32, 100]
    - Source layout:    Not specified
    - Target layout:    Not specified
    - Layout:   input(NCHW)
    - Mean values:  input[127.5]
    - Scale values:     input[127.5]
    - Scale factor:     Not specified
    - Precision of IR:  FP16
    - Enable fusing:    True
    - User transformations:     Not specified
    - Reverse input channels:   False
    - Enable IR generation for fixed input shape:   False
    - Use the transformations config file:  None
Advanced parameters:
    - Force the usage of legacy Frontend of Model Optimizer for model conversion into IR:   False
    - Force the usage of new Frontend of Model Optimizer for model conversion into IR:  False
OpenVINO runtime found in:  /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/openvino
OpenVINO runtime version:   2022.1.0-7019-cdb9bec7210-releases/2022/1
Model Optimizer version:    2022.1.0-7019-cdb9bec7210-releases/2022/1
[ SUCCESS ] Generated IR version 11 model.
[ SUCCESS ] XML file: /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/FP16/text-recognition-resnet-fc.xml
[ SUCCESS ] BIN file: /home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/FP16/text-recognition-resnet-fc.bin
[ SUCCESS ] Total execution time: 4.30 seconds.
[ SUCCESS ] Memory consumed: 1443 MB.
It's been a while, check for a new version of Intel(R) Distribution of OpenVINO(TM) toolkit here https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html?cid=other&source=prod&campid=ww_2022_bu_IOTG_OpenVINO-2022-1&content=upg_all&medium=organic or on the GitHub*
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai

Copy Models

To make it easier to work with the models, we copy the models from the Open Model Zoo tree to the model subdirectory relative to this Jupyter notebook. We get the path to the Open Model Zoo model directory from Open Model Zoo’s omz_info_dumper tool.

models_info_output = %sx omz_info_dumper --name $detection_model,$recognition_model
print(f'sx omz_info_dumper --name {detection_model},{recognition_model}')
detection_model_info, recognition_model_info = [
    {
        "name": "horizontal-text-detection-0001",
        "composite_model_name": None,
        "description": "Horizontal text detector based on FCOS with light MobileNetV2 backbone",
        "framework": "dldt",
        "license_url": "https://raw.githubusercontent.com/openvinotoolkit/open_model_zoo/master/LICENSE",
        "precisions": [
            "FP16",
            "FP16-INT8",
            "FP32"
        ],
        "quantization_output_precisions": [],
        "subdirectory": "intel/horizontal-text-detection-0001",
        "task_type": "detection"
    },
    {
        "name": "text-recognition-resnet-fc",
        "composite_model_name": None,
        "description": "\"text-recognition-resnet-fc\" is a simple and preformant scene text recognition model based on ResNet with Fully Connected text recognition head. Source implementation on a PyTorch* framework could be found here <https://github.com/Media-Smart/vedastr>. Model is able to recognize alphanumeric text.",
        "framework": "pytorch",
        "license_url": "https://raw.githubusercontent.com/Media-Smart/vedastr/0fd2a0bd7819ae4daa2a161501e9f1c2ac67e96a/LICENSE",
        "precisions": [
            "FP16",
            "FP32"
        ],
        "quantization_output_precisions": [],
        "subdirectory": "public/text-recognition-resnet-fc",
        "task_type": "optical_character_recognition"
    }
]

for model_info in (detection_model_info, recognition_model_info):
    omz_dir = Path(model_info["subdirectory"])
    omz_model_dir = base_model_dir / omz_dir / precision
    print(omz_model_dir)
    for model_file in omz_model_dir.iterdir():
        try:
            shutil.copyfile(model_file, model_dir / model_file.name)
        except FileExistsError:
            pass

detection_model_path = (model_dir / detection_model).with_suffix(".xml")
recognition_model_path = (model_dir / recognition_model).with_suffix(".xml")
sx omz_info_dumper --name horizontal-text-detection-0001,text-recognition-resnet-fc
/home/runner/open_model_zoo_models/intel/horizontal-text-detection-0001/FP16
/home/runner/open_model_zoo_models/public/text-recognition-resnet-fc/FP16

Object Detection

Load the detection model, load an image, do inference and get the detection inference result.

Load Detection Model

detection_model = ie.read_model(
    model=detection_model_path, weights=detection_model_path.with_suffix(".bin")
)
detection_compiled_model = ie.compile_model(model=detection_model, device_name="CPU")

detection_input_layer = detection_compiled_model.input(0)

Load an Image

# image_file can point to a URL or local image
image_file = "https://github.com/openvinotoolkit/openvino_notebooks/raw/main/notebooks/004-hello-detection/data/intel_rnb.jpg"

image = load_image(image_file)

# N,C,H,W = batch size, number of channels, height, width
N, C, H, W = detection_input_layer.shape

# Resize image to meet network expected input sizes
resized_image = cv2.resize(image, (W, H))

# Reshape to network input shape
input_image = np.expand_dims(resized_image.transpose(2, 0, 1), 0)

plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB));
../_images/208-optical-character-recognition-with-output_15_0.png

Do Inference

Text boxes are detected in the images and returned as blobs of data in the shape of [100, 5]. Each detection description has the format [x_min, y_min, x_max, y_max, conf].

output_key = detection_compiled_model.output("boxes")
boxes = detection_compiled_model([input_image])[output_key]

# Remove zero only boxes
boxes = boxes[~np.all(boxes == 0, axis=1)]

Get Detection Results

def multiply_by_ratio(ratio_x, ratio_y, box):
    return [
        max(shape * ratio_y, 10) if idx % 2 else shape * ratio_x
        for idx, shape in enumerate(box[:-1])
    ]


def run_preprocesing_on_crop(crop, net_shape):
    temp_img = cv2.resize(crop, net_shape)
    temp_img = temp_img.reshape((1,) * 2 + temp_img.shape)
    return temp_img


def convert_result_to_image(bgr_image, resized_image, boxes, threshold=0.3, conf_labels=True):
    # Define colors for boxes and descriptions
    colors = {"red": (255, 0, 0), "green": (0, 255, 0), "white": (255, 255, 255)}

    # Fetch image shapes to calculate ratio
    (real_y, real_x), (resized_y, resized_x) = image.shape[:2], resized_image.shape[:2]
    ratio_x, ratio_y = real_x / resized_x, real_y / resized_y

    # Convert base image from bgr to rgb format
    rgb_image = cv2.cvtColor(bgr_image, cv2.COLOR_BGR2RGB)

    # Iterate through non-zero boxes
    for box, annotation in boxes:
        # Pick confidence factor from last place in array
        conf = box[-1]
        if conf > threshold:
            # Convert float to int and multiply position of each box by x and y ratio
            (x_min, y_min, x_max, y_max) = map(int, multiply_by_ratio(ratio_x, ratio_y, box))

            # Draw box based on position, parameters in rectangle function are: image, start_point, end_point, color, thickness
            cv2.rectangle(rgb_image, (x_min, y_min), (x_max, y_max), colors["green"], 3)

            # Add text to image based on position and confidence, parameters in putText function are: image, text, bottomleft_corner_textfield, font, font_scale, color, thickness, line_type
            if conf_labels:
                # Create background box based on annotation length
                (text_w, text_h), _ = cv2.getTextSize(
                    f"{annotation}", cv2.FONT_HERSHEY_TRIPLEX, 0.8, 1
                )
                image_copy = rgb_image.copy()
                cv2.rectangle(
                    image_copy,
                    (x_min, y_min - text_h - 10),
                    (x_min + text_w, y_min - 10),
                    colors["white"],
                    -1,
                )
                # Add weighted image copy with white boxes under text
                cv2.addWeighted(image_copy, 0.4, rgb_image, 0.6, 0, rgb_image)
                cv2.putText(
                    rgb_image,
                    f"{annotation}",
                    (x_min, y_min - 10),
                    cv2.FONT_HERSHEY_SIMPLEX,
                    0.8,
                    colors["red"],
                    1,
                    cv2.LINE_AA,
                )

    return rgb_image

Text Recogntion

Load the text recognition model and do inference on the detected boxes from the detection model.

Load Text Recognition Model

recognition_model = ie.read_model(
    model=recognition_model_path, weights=recognition_model_path.with_suffix(".bin")
)

recognition_compiled_model = ie.compile_model(model=recognition_model, device_name="CPU")

recognition_output_layer = recognition_compiled_model.output(0)
recognition_input_layer = recognition_compiled_model.input(0)

# Get height and width of input layer
_, _, H, W = recognition_input_layer.shape

Do Inference

# Calculate scale for image resizing
(real_y, real_x), (resized_y, resized_x) = image.shape[:2], resized_image.shape[:2]
ratio_x, ratio_y = real_x / resized_x, real_y / resized_y

# Convert image to grayscale for text recognition model
grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Get dictionary to encode output, based on model documentation
letters = "~0123456789abcdefghijklmnopqrstuvwxyz"

# Prepare empty list for annotations
annotations = list()
cropped_images = list()
# fig, ax = plt.subplots(len(boxes), 1, figsize=(5,15), sharex=True, sharey=True)
# For each crop, based on boxes given by detection model we want to get annotations
for i, crop in enumerate(boxes):
    # Get coordinates on corners of crop
    (x_min, y_min, x_max, y_max) = map(int, multiply_by_ratio(ratio_x, ratio_y, crop))
    image_crop = run_preprocesing_on_crop(grayscale_image[y_min:y_max, x_min:x_max], (W, H))

    # Run inference with recognition model
    result = recognition_compiled_model([image_crop])[recognition_output_layer]

    # Squeeze output to remove unnececery dimension
    recognition_results_test = np.squeeze(result)

    # Read annotation based on probabilities from output layer
    annotation = list()
    for letter in recognition_results_test:
        parsed_letter = letters[letter.argmax()]

        # Returning 0 index from argmax signalises end of string
        if parsed_letter == letters[0]:
            break
        annotation.append(parsed_letter)
    annotations.append("".join(annotation))
    cropped_image = Image.fromarray(image[y_min:y_max, x_min:x_max])
    cropped_images.append(cropped_image)

boxes_with_annotations = list(zip(boxes, annotations))

Show Results

Show Detected Text Boxes and OCR Results for the Image

Visualize the result by drawing boxes around recognized text and showing the OCR result from the text recognition model

plt.figure(figsize=(12, 12))
plt.imshow(convert_result_to_image(image, resized_image, boxes_with_annotations, conf_labels=True));
../_images/208-optical-character-recognition-with-output_25_0.png

Show the OCR Result per Bounding Box

Depending on the image, the OCR result may not be readable in the image with boxes as displayed in the cell above. In the next cell, we show the extracted boxes, and the OCR result per box.

for cropped_image, annotation in zip(cropped_images, annotations):
    display(cropped_image, Markdown("".join(annotation)))
../_images/208-optical-character-recognition-with-output_27_0.png

building

../_images/208-optical-character-recognition-with-output_27_2.png

noyce

../_images/208-optical-character-recognition-with-output_27_4.png

2200

../_images/208-optical-character-recognition-with-output_27_6.png

n

../_images/208-optical-character-recognition-with-output_27_8.png

center

../_images/208-optical-character-recognition-with-output_27_10.png

robert