Optical Character Recognition (OCR) with OpenVINO

This tutorial is also available as a Jupyter notebook that can be cloned directly from GitHub. See the installation guide for instructions to run this tutorial locally on Windows, Linux or macOS.

Github

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 /opt/home/k8sworker/open_model_zoo_models --cache_dir /opt/home/k8sworker/open_model_zoo_cache --precision FP16

⠧ Downloading horizontal-text-detection-0001, text-recognition-resnet-fc['################|| Downloading horizontal-text-detection-0001 ||################', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/intel/horizontal-text-detection-0001/FP16/horizontal-text-detection-0001.xml', '... 100%, 956 KB, 4553 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/intel/horizontal-text-detection-0001/FP16/horizontal-text-detection-0001.bin', '... 27%, 1024 KB, 6800 KB/s, 0 seconds passed', '... 54%, 2048 KB, 8310 KB/s, 0 seconds passed', '... 81%, 3072 KB, 10405 KB/s, 0 seconds passed', '... 100%, 3786 KB, 10332 KB/s, 0 seconds passed', '', '################|| Downloading text-recognition-resnet-fc ||################', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/__init__.py', '... 100%, 0 KB, 78 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/builder.py', '... 100%, 0 KB, 560 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/model.py', '... 100%, 0 KB, 2097 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/weight_init.py', '... 100%, 3 KB, 9942 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/registry.py', '... 100%, 0 KB, 199 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/__init__.py', '... 100%, 0 KB, 657 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/builder.py', '... 100%, 0 KB, 579 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/fc_head.py', '... 100%, 1 KB, 5565 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/registry.py', '... 100%, 0 KB, 243 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/__init__.py', '... 100%, 0 KB, 1132 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/builder.py', '... 100%, 0 KB, 1086 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/registry.py', '... 100%, 0 KB, 335 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/body.py', '... 100%, 1 KB, 3699 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/component.py', '... 100%, 1 KB, 4548 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/__init__.py', '... 100%, 0 KB, 491 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/builder.py', '... 100%, 0 KB, 1325 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/registry.py', '... 100%, 0 KB, 464 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/__init__.py', '... 100%, 0 KB, 591 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/builder.py', '... 100%, 0 KB, 2358 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/__init__.py', '... 100%, 0 KB, 361 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/builder.py', '... 100%, 0 KB, 650 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/registry.py', '... 100%, 0 KB, 234 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/__init__.py', '... 100%, 0 KB, 532 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/bricks.py', '... 100%, 6 KB, 18188 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/builder.py', '... 100%, 0 KB, 1178 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/registry.py', '... 100%, 0 KB, 205 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/__init__.py', '... 100%, 0 KB, 306 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/builder.py', '... 100%, 0 KB, 1177 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/__init__.py', '... 100%, 0 KB, 254 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/builder.py', '... 100%, 0 KB, 688 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/registry.py', '... 100%, 0 KB, 241 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/resnet.py', '... 100%, 8 KB, 21594 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/__init__.py', '... 100%, 0 KB, 300 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/builder.py', '... 100%, 0 KB, 723 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/registry.py', '... 100%, 0 KB, 282 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/__init__.py', '... 100%, 0 KB, 682 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/builder.py', '... 100%, 0 KB, 1096 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/conv_module.py', '... 100%, 7 KB, 17490 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/fc_module.py', '... 100%, 2 KB, 8092 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/norm.py', '... 100%, 1 KB, 5163 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/registry.py', '... 100%, 0 KB, 194 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/__init__.py', '... 100%, 0 KB, 855 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/common.py', '... 100%, 3 KB, 9449 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/registry.py', '... 100%, 1 KB, 3889 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '... 100%, 5 KB, 13890 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/configs/resnet_fc.py', '... 100%, 8 KB, 21043 KB/s, 0 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/ckpt/resnet_fc.pth', '... 0%, 1024 KB, 5232 KB/s, 0 seconds passed', '... 0%, 2048 KB, 7094 KB/s, 0 seconds passed', '... 0%, 3072 KB, 8448 KB/s, 0 seconds passed', '... 0%, 4096 KB, 9227 KB/s, 0 seconds passed', '... 0%, 5120 KB, 10243 KB/s, 0 seconds passed', '... 0%, 6144 KB, 10903 KB/s, 0 seconds passed', '... 1%, 7168 KB, 11506 KB/s, 0 seconds passed', '... 1%, 8192 KB, 12044 KB/s, 0 seconds passed', '... 1%, 9216 KB, 12673 KB/s, 0 seconds passed', '... 1%, 10240 KB, 13209 KB/s, 0 seconds passed', '... 1%, 11264 KB, 13761 KB/s, 0 seconds passed', '... 1%, 12288 KB, 14185 KB/s, 0 seconds passed', '... 1%, 13312 KB, 14687 KB/s, 0 seconds passed', '... 2%, 14336 KB, 15154 KB/s, 0 seconds passed', '... 2%, 15360 KB, 15579 KB/s, 0 seconds passed', '... 2%, 16384 KB, 15952 KB/s, 1 seconds passed', '... 2%, 17408 KB, 16295 KB/s, 1 seconds passed', '... 2%, 18432 KB, 16643 KB/s, 1 seconds passed', '... 2%, 19456 KB, 16952 KB/s, 1 seconds passed', '... 2%, 20480 KB, 17263 KB/s, 1 seconds passed', '... 3%, 21504 KB, 17640 KB/s, 1 seconds passed', '... 3%, 22528 KB, 18068 KB/s, 1 seconds passed', '... 3%, 23552 KB, 18454 KB/s, 1 seconds passed', '... 3%, 24576 KB, 18809 KB/s, 1 seconds passed', '... 3%, 25600 KB, 19193 KB/s, 1 seconds passed', '... 3%, 26624 KB, 19509 KB/s, 1 seconds passed', '... 3%, 27648 KB, 19856 KB/s, 1 seconds passed', '... 4%, 28672 KB, 20174 KB/s, 1 seconds passed', '... 4%, 29696 KB, 20469 KB/s, 1 seconds passed', '... 4%, 30720 KB, 20760 KB/s, 1 seconds passed', '... 4%, 31744 KB, 20109 KB/s, 1 seconds passed', '... 4%, 32768 KB, 20010 KB/s, 1 seconds passed', '... 4%, 33792 KB, 20139 KB/s, 1 seconds passed', '... 5%, 34816 KB, 20030 KB/s, 1 seconds passed', '... 5%, 35840 KB, 19750 KB/s, 1 seconds passed', '... 5%, 36864 KB, 19797 KB/s, 1 seconds passed', '... 5%, 37888 KB, 19310 KB/s, 1 seconds passed', '... 5%, 38912 KB, 18826 KB/s, 2 seconds passed', '... 5%, 39936 KB, 18470 KB/s, 2 seconds passed', '... 5%, 40960 KB, 18069 KB/s, 2 seconds passed', '... 6%, 41984 KB, 17710 KB/s, 2 seconds passed', '... 6%, 43008 KB, 17504 KB/s, 2 seconds passed', '... 6%, 44032 KB, 17215 KB/s, 2 seconds passed', '... 6%, 45056 KB, 16954 KB/s, 2 seconds passed', '... 6%, 46080 KB, 16524 KB/s, 2 seconds passed', '... 6%, 47104 KB, 16161 KB/s, 2 seconds passed', '... 6%, 48128 KB, 15553 KB/s, 3 seconds passed', '... 7%, 49152 KB, 15051 KB/s, 3 seconds passed', '... 7%, 50176 KB, 14594 KB/s, 3 seconds passed', '... 7%, 51200 KB, 14235 KB/s, 3 seconds passed', '... 7%, 52224 KB, 13899 KB/s, 3 seconds passed', '... 7%, 53248 KB, 13665 KB/s, 3 seconds passed', '... 7%, 54272 KB, 13384 KB/s, 4 seconds passed', '... 7%, 55296 KB, 13181 KB/s, 4 seconds passed', '... 8%, 56320 KB, 12961 KB/s, 4 seconds passed', '... 8%, 57344 KB, 12798 KB/s, 4 seconds passed', '... 8%, 58368 KB, 12664 KB/s, 4 seconds passed', '... 8%, 59392 KB, 12530 KB/s, 4 seconds passed', '... 8%, 60416 KB, 12422 KB/s, 4 seconds passed', '... 8%, 61440 KB, 12346 KB/s, 4 seconds passed', '... 8%, 62464 KB, 12245 KB/s, 5 seconds passed', '... 9%, 63488 KB, 12193 KB/s, 5 seconds passed', '... 9%, 64512 KB, 12148 KB/s, 5 seconds passed', '... 9%, 65536 KB, 12095 KB/s, 5 seconds passed', '... 9%, 66560 KB, 12089 KB/s, 5 seconds passed', '... 9%, 67584 KB, 12075 KB/s, 5 seconds passed', '... 9%, 68608 KB, 12060 KB/s, 5 seconds passed', '... 10%, 69632 KB, 12059 KB/s, 5 seconds passed', '... 10%, 70656 KB, 12069 KB/s, 5 seconds passed', '... 10%, 71680 KB, 12092 KB/s, 5 seconds passed', '... 10%, 72704 KB, 12092 KB/s, 6 seconds passed', '... 10%, 73728 KB, 12116 KB/s, 6 seconds passed', '... 10%, 74752 KB, 12142 KB/s, 6 seconds passed', '... 10%, 75776 KB, 12163 KB/s, 6 seconds passed', '... 11%, 76800 KB, 12191 KB/s, 6 seconds passed', '... 11%, 77824 KB, 12225 KB/s, 6 seconds passed', '... 11%, 78848 KB, 12205 KB/s, 6 seconds passed', '... 11%, 79872 KB, 12215 KB/s, 6 seconds passed', '... 11%, 80896 KB, 12148 KB/s, 6 seconds passed', '... 11%, 81920 KB, 12091 KB/s, 6 seconds passed', '... 11%, 82944 KB, 12023 KB/s, 6 seconds passed', '... 12%, 83968 KB, 11965 KB/s, 7 seconds passed', '... 12%, 84992 KB, 11902 KB/s, 7 seconds passed', '... 12%, 86016 KB, 11870 KB/s, 7 seconds passed', '... 12%, 87040 KB, 11843 KB/s, 7 seconds passed', '... 12%, 88064 KB, 11799 KB/s, 7 seconds passed', '... 12%, 89088 KB, 11771 KB/s, 7 seconds passed', '... 12%, 90112 KB, 11745 KB/s, 7 seconds passed', '... 13%, 91136 KB, 11716 KB/s, 7 seconds passed', '... 13%, 92160 KB, 11687 KB/s, 7 seconds passed', '... 13%, 93184 KB, 11660 KB/s, 7 seconds passed', '... 13%, 94208 KB, 11638 KB/s, 8 seconds passed', '... 13%, 95232 KB, 11616 KB/s, 8 seconds passed', '... 13%, 96256 KB, 11604 KB/s, 8 seconds passed', '... 13%, 97280 KB, 11587 KB/s, 8 seconds passed', '... 14%, 98304 KB, 11588 KB/s, 8 seconds passed', '... 14%, 99328 KB, 11579 KB/s, 8 seconds passed', '... 14%, 100352 KB, 11576 KB/s, 8 seconds passed', '... 14%, 101376 KB, 11576 KB/s, 8 seconds passed', '... 14%, 102400 KB, 11589 KB/s, 8 seconds passed', '... 14%, 103424 KB, 11589 KB/s, 8 seconds passed', '... 15%, 104448 KB, 11608 KB/s, 8 seconds passed', '... 15%, 105472 KB, 11627 KB/s, 9 seconds passed', '... 15%, 106496 KB, 11622 KB/s, 9 seconds passed', '... 15%, 107520 KB, 11639 KB/s, 9 seconds passed', '... 15%, 108544 KB, 11655 KB/s, 9 seconds passed', '... 15%, 109568 KB, 11647 KB/s, 9 seconds passed', '... 15%, 110592 KB, 11629 KB/s, 9 seconds passed', '... 16%, 111616 KB, 11572 KB/s, 9 seconds passed', '... 16%, 112640 KB, 11532 KB/s, 9 seconds passed', '... 16%, 113664 KB, 11488 KB/s, 9 seconds passed', '... 16%, 114688 KB, 11445 KB/s, 10 seconds passed', '... 16%, 115712 KB, 11387 KB/s, 10 seconds passed', '... 16%, 116736 KB, 11238 KB/s, 10 seconds passed', '... 16%, 117760 KB, 11102 KB/s, 10 seconds passed', '... 17%, 118784 KB, 10982 KB/s, 10 seconds passed', '... 17%, 119808 KB, 10845 KB/s, 11 seconds passed', '... 17%, 120832 KB, 10738 KB/s, 11 seconds passed', '... 17%, 121856 KB, 10655 KB/s, 11 seconds passed', '... 17%, 122880 KB, 10562 KB/s, 11 seconds passed', '... 17%, 123904 KB, 10491 KB/s, 11 seconds passed', '... 17%, 124928 KB, 10412 KB/s, 11 seconds passed', '... 18%, 125952 KB, 10370 KB/s, 12 seconds passed', '... 18%, 126976 KB, 10318 KB/s, 12 seconds passed', '... 18%, 128000 KB, 10282 KB/s, 12 seconds passed', '... 18%, 129024 KB, 10247 KB/s, 12 seconds passed', '... 18%, 130048 KB, 10227 KB/s, 12 seconds passed', '... 18%, 131072 KB, 10213 KB/s, 12 seconds passed', '... 18%, 132096 KB, 10200 KB/s, 12 seconds passed', '... 19%, 133120 KB, 10193 KB/s, 13 seconds passed', '... 19%, 134144 KB, 10175 KB/s, 13 seconds passed', '... 19%, 135168 KB, 10128 KB/s, 13 seconds passed', '... 19%, 136192 KB, 9979 KB/s, 13 seconds passed', '... 19%, 137216 KB, 9806 KB/s, 13 seconds passed', '... 19%, 138240 KB, 9554 KB/s, 14 seconds passed', '... 20%, 139264 KB, 9334 KB/s, 14 seconds passed', '... 20%, 140288 KB, 9167 KB/s, 15 seconds passed', '... 20%, 141312 KB, 9036 KB/s, 15 seconds passed', '... 20%, 142336 KB, 8937 KB/s, 15 seconds passed', '... 20%, 143360 KB, 8825 KB/s, 16 seconds passed', '... 20%, 144384 KB, 8652 KB/s, 16 seconds passed', '... 20%, 145408 KB, 8524 KB/s, 17 seconds passed', '... 21%, 146432 KB, 8410 KB/s, 17 seconds passed', '... 21%, 147456 KB, 8333 KB/s, 17 seconds passed', '... 21%, 148480 KB, 8242 KB/s, 18 seconds passed', '... 21%, 149504 KB, 8131 KB/s, 18 seconds passed', '... 21%, 150528 KB, 7938 KB/s, 18 seconds passed', '... 21%, 151552 KB, 7807 KB/s, 19 seconds passed', '... 21%, 152576 KB, 7705 KB/s, 19 seconds passed', '... 22%, 153600 KB, 7625 KB/s, 20 seconds passed', '... 22%, 154624 KB, 7566 KB/s, 20 seconds passed', '... 22%, 155648 KB, 7521 KB/s, 20 seconds passed', '... 22%, 156672 KB, 7496 KB/s, 20 seconds passed', '... 22%, 157696 KB, 7482 KB/s, 21 seconds passed', '... 22%, 158720 KB, 7474 KB/s, 21 seconds passed', '... 22%, 159744 KB, 7471 KB/s, 21 seconds passed', '... 23%, 160768 KB, 7470 KB/s, 21 seconds passed', '... 23%, 161792 KB, 7465 KB/s, 21 seconds passed', '... 23%, 162816 KB, 7436 KB/s, 21 seconds passed', '... 23%, 163840 KB, 7406 KB/s, 22 seconds passed', '... 23%, 164864 KB, 7382 KB/s, 22 seconds passed', '... 23%, 165888 KB, 7338 KB/s, 22 seconds passed', '... 23%, 166912 KB, 7270 KB/s, 22 seconds passed', '... 24%, 167936 KB, 7214 KB/s, 23 seconds passed', '... 24%, 168960 KB, 7167 KB/s, 23 seconds passed', '... 24%, 169984 KB, 7129 KB/s, 23 seconds passed', '... 24%, 171008 KB, 7099 KB/s, 24 seconds passed', '... 24%, 172032 KB, 7071 KB/s, 24 seconds passed', '... 24%, 173056 KB, 7050 KB/s, 24 seconds passed', '... 25%, 174080 KB, 7038 KB/s, 24 seconds passed', '... 25%, 175104 KB, 7029 KB/s, 24 seconds passed', '... 25%, 176128 KB, 7027 KB/s, 25 seconds passed', '... 25%, 177152 KB, 7030 KB/s, 25 seconds passed', '... 25%, 178176 KB, 7032 KB/s, 25 seconds passed', '... 25%, 179200 KB, 7041 KB/s, 25 seconds passed', '... 25%, 180224 KB, 7051 KB/s, 25 seconds passed', '... 26%, 181248 KB, 7056 KB/s, 25 seconds passed', '... 26%, 182272 KB, 7053 KB/s, 25 seconds passed', '... 26%, 183296 KB, 7044 KB/s, 26 seconds passed', '... 26%, 184320 KB, 7035 KB/s, 26 seconds passed', '... 26%, 185344 KB, 7029 KB/s, 26 seconds passed', '... 26%, 186368 KB, 7024 KB/s, 26 seconds passed', '... 26%, 187392 KB, 7021 KB/s, 26 seconds passed', '... 27%, 188416 KB, 7017 KB/s, 26 seconds passed', '... 27%, 189440 KB, 7019 KB/s, 26 seconds passed', '... 27%, 190464 KB, 7015 KB/s, 27 seconds passed', '... 27%, 191488 KB, 7012 KB/s, 27 seconds passed', '... 27%, 192512 KB, 7016 KB/s, 27 seconds passed', '... 27%, 193536 KB, 7019 KB/s, 27 seconds passed', '... 27%, 194560 KB, 7022 KB/s, 27 seconds passed', '... 28%, 195584 KB, 7028 KB/s, 27 seconds passed', '... 28%, 196608 KB, 7035 KB/s, 27 seconds passed', '... 28%, 197632 KB, 7046 KB/s, 28 seconds passed', '... 28%, 198656 KB, 7056 KB/s, 28 seconds passed', '... 28%, 199680 KB, 7067 KB/s, 28 seconds passed', '... 28%, 200704 KB, 7078 KB/s, 28 seconds passed', '... 29%, 201728 KB, 7093 KB/s, 28 seconds passed', '... 29%, 202752 KB, 7108 KB/s, 28 seconds passed', '... 29%, 203776 KB, 7123 KB/s, 28 seconds passed', '... 29%, 204800 KB, 7138 KB/s, 28 seconds passed', '... 29%, 205824 KB, 7154 KB/s, 28 seconds passed', '... 29%, 206848 KB, 7171 KB/s, 28 seconds passed', '... 29%, 207872 KB, 7188 KB/s, 28 seconds passed', '... 30%, 208896 KB, 7206 KB/s, 28 seconds passed', '... 30%, 209920 KB, 7224 KB/s, 29 seconds passed', '... 30%, 210944 KB, 7242 KB/s, 29 seconds passed', '... 30%, 211968 KB, 7259 KB/s, 29 seconds passed', '... 30%, 212992 KB, 7277 KB/s, 29 seconds passed', '... 30%, 214016 KB, 7300 KB/s, 29 seconds passed', '... 30%, 215040 KB, 7319 KB/s, 29 seconds passed', '... 31%, 216064 KB, 7340 KB/s, 29 seconds passed', '... 31%, 217088 KB, 7359 KB/s, 29 seconds passed', '... 31%, 218112 KB, 7379 KB/s, 29 seconds passed', '... 31%, 219136 KB, 7401 KB/s, 29 seconds passed', '... 31%, 220160 KB, 7418 KB/s, 29 seconds passed', '... 31%, 221184 KB, 7426 KB/s, 29 seconds passed', '... 31%, 222208 KB, 7434 KB/s, 29 seconds passed', '... 32%, 223232 KB, 7443 KB/s, 29 seconds passed', '... 32%, 224256 KB, 7451 KB/s, 30 seconds passed', '... 32%, 225280 KB, 7458 KB/s, 30 seconds passed', '... 32%, 226304 KB, 7466 KB/s, 30 seconds passed', '... 32%, 227328 KB, 7473 KB/s, 30 seconds passed', '... 32%, 228352 KB, 7474 KB/s, 30 seconds passed', '... 32%, 229376 KB, 7461 KB/s, 30 seconds passed', '... 33%, 230400 KB, 7454 KB/s, 30 seconds passed', '... 33%, 231424 KB, 7442 KB/s, 31 seconds passed', '... 33%, 232448 KB, 7433 KB/s, 31 seconds passed', '... 33%, 233472 KB, 7424 KB/s, 31 seconds passed', '... 33%, 234496 KB, 7418 KB/s, 31 seconds passed', '... 33%, 235520 KB, 7414 KB/s, 31 seconds passed', '... 34%, 236544 KB, 7411 KB/s, 31 seconds passed', '... 34%, 237568 KB, 7408 KB/s, 32 seconds passed', '... 34%, 238592 KB, 7411 KB/s, 32 seconds passed', '... 34%, 239616 KB, 7412 KB/s, 32 seconds passed', '... 34%, 240640 KB, 7414 KB/s, 32 seconds passed', '... 34%, 241664 KB, 7418 KB/s, 32 seconds passed', '... 34%, 242688 KB, 7421 KB/s, 32 seconds passed', '... 35%, 243712 KB, 7426 KB/s, 32 seconds passed', '... 35%, 244736 KB, 7432 KB/s, 32 seconds passed', '... 35%, 245760 KB, 7439 KB/s, 33 seconds passed', '... 35%, 246784 KB, 7449 KB/s, 33 seconds passed', '... 35%, 247808 KB, 7457 KB/s, 33 seconds passed', '... 35%, 248832 KB, 7472 KB/s, 33 seconds passed', '... 35%, 249856 KB, 7482 KB/s, 33 seconds passed', '... 36%, 250880 KB, 7492 KB/s, 33 seconds passed', '... 36%, 251904 KB, 7507 KB/s, 33 seconds passed', '... 36%, 252928 KB, 7520 KB/s, 33 seconds passed', '... 36%, 253952 KB, 7533 KB/s, 33 seconds passed', '... 36%, 254976 KB, 7548 KB/s, 33 seconds passed', '... 36%, 256000 KB, 7562 KB/s, 33 seconds passed', '... 36%, 257024 KB, 7576 KB/s, 33 seconds passed', '... 37%, 258048 KB, 7589 KB/s, 33 seconds passed', '... 37%, 259072 KB, 7597 KB/s, 34 seconds passed', '... 37%, 260096 KB, 7601 KB/s, 34 seconds passed', '... 37%, 261120 KB, 7605 KB/s, 34 seconds passed', '... 37%, 262144 KB, 7606 KB/s, 34 seconds passed', '... 37%, 263168 KB, 7609 KB/s, 34 seconds passed', '... 37%, 264192 KB, 7616 KB/s, 34 seconds passed', '... 38%, 265216 KB, 7619 KB/s, 34 seconds passed', '... 38%, 266240 KB, 7622 KB/s, 34 seconds passed', '... 38%, 267264 KB, 7629 KB/s, 35 seconds passed', '... 38%, 268288 KB, 7635 KB/s, 35 seconds passed', '... 38%, 269312 KB, 7642 KB/s, 35 seconds passed', '... 38%, 270336 KB, 7648 KB/s, 35 seconds passed', '... 39%, 271360 KB, 7654 KB/s, 35 seconds passed', '... 39%, 272384 KB, 7662 KB/s, 35 seconds passed', '... 39%, 273408 KB, 7669 KB/s, 35 seconds passed', '... 39%, 274432 KB, 7677 KB/s, 35 seconds passed', '... 39%, 275456 KB, 7684 KB/s, 35 seconds passed', '... 39%, 276480 KB, 7691 KB/s, 35 seconds passed', '... 39%, 277504 KB, 7700 KB/s, 36 seconds passed', '... 40%, 278528 KB, 7710 KB/s, 36 seconds passed', '... 40%, 279552 KB, 7719 KB/s, 36 seconds passed', '... 40%, 280576 KB, 7729 KB/s, 36 seconds passed', '... 40%, 281600 KB, 7739 KB/s, 36 seconds passed', '... 40%, 282624 KB, 7751 KB/s, 36 seconds passed', '... 40%, 283648 KB, 7761 KB/s, 36 seconds passed', '... 40%, 284672 KB, 7773 KB/s, 36 seconds passed', '... 41%, 285696 KB, 7785 KB/s, 36 seconds passed', '... 41%, 286720 KB, 7791 KB/s, 36 seconds passed', '... 41%, 287744 KB, 7791 KB/s, 36 seconds passed', '... 41%, 288768 KB, 7785 KB/s, 37 seconds passed', '... 41%, 289792 KB, 7785 KB/s, 37 seconds passed', '... 41%, 290816 KB, 7782 KB/s, 37 seconds passed', '... 41%, 291840 KB, 7783 KB/s, 37 seconds passed', '... 42%, 292864 KB, 7783 KB/s, 37 seconds passed', '... 42%, 293888 KB, 7784 KB/s, 37 seconds passed', '... 42%, 294912 KB, 7784 KB/s, 37 seconds passed', '... 42%, 295936 KB, 7788 KB/s, 37 seconds passed', '... 42%, 296960 KB, 7791 KB/s, 38 seconds passed', '... 42%, 297984 KB, 7780 KB/s, 38 seconds passed', '... 42%, 299008 KB, 7759 KB/s, 38 seconds passed', '... 43%, 300032 KB, 7744 KB/s, 38 seconds passed', '... 43%, 301056 KB, 7729 KB/s, 38 seconds passed', '... 43%, 302080 KB, 7718 KB/s, 39 seconds passed', '... 43%, 303104 KB, 7711 KB/s, 39 seconds passed', '... 43%, 304128 KB, 7701 KB/s, 39 seconds passed', '... 43%, 305152 KB, 7693 KB/s, 39 seconds passed', '... 44%, 306176 KB, 7684 KB/s, 39 seconds passed', '... 44%, 307200 KB, 7678 KB/s, 40 seconds passed', '... 44%, 308224 KB, 7675 KB/s, 40 seconds passed', '... 44%, 309248 KB, 7673 KB/s, 40 seconds passed', '... 44%, 310272 KB, 7673 KB/s, 40 seconds passed', '... 44%, 311296 KB, 7675 KB/s, 40 seconds passed', '... 44%, 312320 KB, 7676 KB/s, 40 seconds passed', '... 45%, 313344 KB, 7680 KB/s, 40 seconds passed', '... 45%, 314368 KB, 7685 KB/s, 40 seconds passed', '... 45%, 315392 KB, 7690 KB/s, 41 seconds passed', '... 45%, 316416 KB, 7696 KB/s, 41 seconds passed', '... 45%, 317440 KB, 7703 KB/s, 41 seconds passed', '... 45%, 318464 KB, 7713 KB/s, 41 seconds passed', '... 45%, 319488 KB, 7722 KB/s, 41 seconds passed', '... 46%, 320512 KB, 7732 KB/s, 41 seconds passed', '... 46%, 321536 KB, 7742 KB/s, 41 seconds passed', '... 46%, 322560 KB, 7754 KB/s, 41 seconds passed', '... 46%, 323584 KB, 7766 KB/s, 41 seconds passed', '... 46%, 324608 KB, 7778 KB/s, 41 seconds passed', '... 46%, 325632 KB, 7790 KB/s, 41 seconds passed', '... 46%, 326656 KB, 7802 KB/s, 41 seconds passed', '... 47%, 327680 KB, 7815 KB/s, 41 seconds passed', '... 47%, 328704 KB, 7830 KB/s, 41 seconds passed', '... 47%, 329728 KB, 7844 KB/s, 42 seconds passed', '... 47%, 330752 KB, 7858 KB/s, 42 seconds passed', '... 47%, 331776 KB, 7871 KB/s, 42 seconds passed', '... 47%, 332800 KB, 7886 KB/s, 42 seconds passed', '... 47%, 333824 KB, 7901 KB/s, 42 seconds passed', '... 48%, 334848 KB, 7914 KB/s, 42 seconds passed', '... 48%, 335872 KB, 7930 KB/s, 42 seconds passed', '... 48%, 336896 KB, 7944 KB/s, 42 seconds passed', '... 48%, 337920 KB, 7959 KB/s, 42 seconds passed', '... 48%, 338944 KB, 7974 KB/s, 42 seconds passed', '... 48%, 339968 KB, 7991 KB/s, 42 seconds passed', '... 49%, 340992 KB, 8005 KB/s, 42 seconds passed', '... 49%, 342016 KB, 8021 KB/s, 42 seconds passed', '... 49%, 343040 KB, 8037 KB/s, 42 seconds passed', '... 49%, 344064 KB, 8053 KB/s, 42 seconds passed', '... 49%, 345088 KB, 8069 KB/s, 42 seconds passed', '... 49%, 346112 KB, 8085 KB/s, 42 seconds passed', '... 49%, 347136 KB, 8101 KB/s, 42 seconds passed', '... 50%, 348160 KB, 8118 KB/s, 42 seconds passed', '... 50%, 349184 KB, 8135 KB/s, 42 seconds passed', '... 50%, 350208 KB, 8150 KB/s, 42 seconds passed', '... 50%, 351232 KB, 8166 KB/s, 43 seconds passed', '... 50%, 352256 KB, 8183 KB/s, 43 seconds passed', '... 50%, 353280 KB, 8199 KB/s, 43 seconds passed', '... 50%, 354304 KB, 8215 KB/s, 43 seconds passed', '... 51%, 355328 KB, 8232 KB/s, 43 seconds passed', '... 51%, 356352 KB, 8248 KB/s, 43 seconds passed', '... 51%, 357376 KB, 8264 KB/s, 43 seconds passed', '... 51%, 358400 KB, 8281 KB/s, 43 seconds passed', '... 51%, 359424 KB, 8297 KB/s, 43 seconds passed', '... 51%, 360448 KB, 8313 KB/s, 43 seconds passed', '... 51%, 361472 KB, 8330 KB/s, 43 seconds passed', '... 52%, 362496 KB, 8346 KB/s, 43 seconds passed', '... 52%, 363520 KB, 8362 KB/s, 43 seconds passed', '... 52%, 364544 KB, 8378 KB/s, 43 seconds passed', '... 52%, 365568 KB, 8394 KB/s, 43 seconds passed', '... 52%, 366592 KB, 8410 KB/s, 43 seconds passed', '... 52%, 367616 KB, 8427 KB/s, 43 seconds passed', '... 53%, 368640 KB, 8442 KB/s, 43 seconds passed', '... 53%, 369664 KB, 8458 KB/s, 43 seconds passed', '... 53%, 370688 KB, 8477 KB/s, 43 seconds passed', '... 53%, 371712 KB, 8494 KB/s, 43 seconds passed', '... 53%, 372736 KB, 8512 KB/s, 43 seconds passed', '... 53%, 373760 KB, 8529 KB/s, 43 seconds passed', '... 53%, 374784 KB, 8547 KB/s, 43 seconds passed', '... 54%, 375808 KB, 8564 KB/s, 43 seconds passed', '... 54%, 376832 KB, 8581 KB/s, 43 seconds passed', '... 54%, 377856 KB, 8598 KB/s, 43 seconds passed', '... 54%, 378880 KB, 8615 KB/s, 43 seconds passed', '... 54%, 379904 KB, 8633 KB/s, 44 seconds passed', '... 54%, 380928 KB, 8650 KB/s, 44 seconds passed', '... 54%, 381952 KB, 8667 KB/s, 44 seconds passed', '... 55%, 382976 KB, 8685 KB/s, 44 seconds passed', '... 55%, 384000 KB, 8703 KB/s, 44 seconds passed', '... 55%, 385024 KB, 8720 KB/s, 44 seconds passed', '... 55%, 386048 KB, 8737 KB/s, 44 seconds passed', '... 55%, 387072 KB, 8754 KB/s, 44 seconds passed', '... 55%, 388096 KB, 8772 KB/s, 44 seconds passed', '... 55%, 389120 KB, 8791 KB/s, 44 seconds passed', '... 56%, 390144 KB, 8809 KB/s, 44 seconds passed', '... 56%, 391168 KB, 8826 KB/s, 44 seconds passed', '... 56%, 392192 KB, 8843 KB/s, 44 seconds passed', '... 56%, 393216 KB, 8862 KB/s, 44 seconds passed', '... 56%, 394240 KB, 8880 KB/s, 44 seconds passed', '... 56%, 395264 KB, 8897 KB/s, 44 seconds passed', '... 56%, 396288 KB, 8914 KB/s, 44 seconds passed', '... 57%, 397312 KB, 8929 KB/s, 44 seconds passed', '... 57%, 398336 KB, 8939 KB/s, 44 seconds passed', '... 57%, 399360 KB, 8956 KB/s, 44 seconds passed', '... 57%, 400384 KB, 8973 KB/s, 44 seconds passed', '... 57%, 401408 KB, 8992 KB/s, 44 seconds passed', '... 57%, 402432 KB, 9009 KB/s, 44 seconds passed', '... 58%, 403456 KB, 9027 KB/s, 44 seconds passed', '... 58%, 404480 KB, 9046 KB/s, 44 seconds passed', '... 58%, 405504 KB, 9063 KB/s, 44 seconds passed', '... 58%, 406528 KB, 9081 KB/s, 44 seconds passed', '... 58%, 407552 KB, 9099 KB/s, 44 seconds passed', '... 58%, 408576 KB, 9117 KB/s, 44 seconds passed', '... 58%, 409600 KB, 9135 KB/s, 44 seconds passed', '... 59%, 410624 KB, 9154 KB/s, 44 seconds passed', '... 59%, 411648 KB, 9171 KB/s, 44 seconds passed', '... 59%, 412672 KB, 9189 KB/s, 44 seconds passed', '... 59%, 413696 KB, 9208 KB/s, 44 seconds passed', '... 59%, 414720 KB, 9225 KB/s, 44 seconds passed', '... 59%, 415744 KB, 9243 KB/s, 44 seconds passed', '... 59%, 416768 KB, 9261 KB/s, 45 seconds passed', '... 60%, 417792 KB, 9278 KB/s, 45 seconds passed', '... 60%, 418816 KB, 9297 KB/s, 45 seconds passed', '... 60%, 419840 KB, 9315 KB/s, 45 seconds passed', '... 60%, 420864 KB, 9334 KB/s, 45 seconds passed', '... 60%, 421888 KB, 9352 KB/s, 45 seconds passed', '... 60%, 422912 KB, 9370 KB/s, 45 seconds passed', '... 60%, 423936 KB, 9388 KB/s, 45 seconds passed', '... 61%, 424960 KB, 9406 KB/s, 45 seconds passed', '... 61%, 425984 KB, 9424 KB/s, 45 seconds passed', '... 61%, 427008 KB, 9443 KB/s, 45 seconds passed', '... 61%, 428032 KB, 9461 KB/s, 45 seconds passed', '... 61%, 429056 KB, 9479 KB/s, 45 seconds passed', '... 61%, 430080 KB, 9498 KB/s, 45 seconds passed', '... 61%, 431104 KB, 9516 KB/s, 45 seconds passed', '... 62%, 432128 KB, 9534 KB/s, 45 seconds passed', '... 62%, 433152 KB, 9553 KB/s, 45 seconds passed', '... 62%, 434176 KB, 9571 KB/s, 45 seconds passed', '... 62%, 435200 KB, 9589 KB/s, 45 seconds passed', '... 62%, 436224 KB, 9608 KB/s, 45 seconds passed', '... 62%, 437248 KB, 9626 KB/s, 45 seconds passed', '... 63%, 438272 KB, 9645 KB/s, 45 seconds passed', '... 63%, 439296 KB, 9663 KB/s, 45 seconds passed', '... 63%, 440320 KB, 9681 KB/s, 45 seconds passed', '... 63%, 441344 KB, 9699 KB/s, 45 seconds passed', '... 63%, 442368 KB, 9718 KB/s, 45 seconds passed', '... 63%, 443392 KB, 9736 KB/s, 45 seconds passed', '... 63%, 444416 KB, 9755 KB/s, 45 seconds passed', '... 64%, 445440 KB, 9773 KB/s, 45 seconds passed', '... 64%, 446464 KB, 9791 KB/s, 45 seconds passed', '... 64%, 447488 KB, 9809 KB/s, 45 seconds passed', '... 64%, 448512 KB, 9828 KB/s, 45 seconds passed', '... 64%, 449536 KB, 9846 KB/s, 45 seconds passed', '... 64%, 450560 KB, 9864 KB/s, 45 seconds passed', '... 64%, 451584 KB, 9882 KB/s, 45 seconds passed', '... 65%, 452608 KB, 9900 KB/s, 45 seconds passed', '... 65%, 453632 KB, 9919 KB/s, 45 seconds passed', '... 65%, 454656 KB, 9936 KB/s, 45 seconds passed', '... 65%, 455680 KB, 9955 KB/s, 45 seconds passed', '... 65%, 456704 KB, 9973 KB/s, 45 seconds passed', '... 65%, 457728 KB, 9991 KB/s, 45 seconds passed', '... 65%, 458752 KB, 10009 KB/s, 45 seconds passed', '... 66%, 459776 KB, 10027 KB/s, 45 seconds passed', '... 66%, 460800 KB, 10045 KB/s, 45 seconds passed', '... 66%, 461824 KB, 10063 KB/s, 45 seconds passed', '... 66%, 462848 KB, 10081 KB/s, 45 seconds passed', '... 66%, 463872 KB, 10099 KB/s, 45 seconds passed', '... 66%, 464896 KB, 10117 KB/s, 45 seconds passed', '... 66%, 465920 KB, 10135 KB/s, 45 seconds passed', '... 67%, 466944 KB, 10153 KB/s, 45 seconds passed', '... 67%, 467968 KB, 10171 KB/s, 46 seconds passed', '... 67%, 468992 KB, 10189 KB/s, 46 seconds passed', '... 67%, 470016 KB, 10208 KB/s, 46 seconds passed', '... 67%, 471040 KB, 10225 KB/s, 46 seconds passed', '... 67%, 472064 KB, 10243 KB/s, 46 seconds passed', '... 68%, 473088 KB, 10260 KB/s, 46 seconds passed', '... 68%, 474112 KB, 10279 KB/s, 46 seconds passed', '... 68%, 475136 KB, 10296 KB/s, 46 seconds passed', '... 68%, 476160 KB, 10315 KB/s, 46 seconds passed', '... 68%, 477184 KB, 10332 KB/s, 46 seconds passed', '... 68%, 478208 KB, 10352 KB/s, 46 seconds passed', '... 68%, 479232 KB, 10368 KB/s, 46 seconds passed', '... 69%, 480256 KB, 10387 KB/s, 46 seconds passed', '... 69%, 481280 KB, 10403 KB/s, 46 seconds passed', '... 69%, 482304 KB, 10423 KB/s, 46 seconds passed', '... 69%, 483328 KB, 10438 KB/s, 46 seconds passed', '... 69%, 484352 KB, 10458 KB/s, 46 seconds passed', '... 69%, 485376 KB, 10474 KB/s, 46 seconds passed', '... 69%, 486400 KB, 10494 KB/s, 46 seconds passed', '... 70%, 487424 KB, 10512 KB/s, 46 seconds passed', '... 70%, 488448 KB, 10529 KB/s, 46 seconds passed', '... 70%, 489472 KB, 10547 KB/s, 46 seconds passed', '... 70%, 490496 KB, 10566 KB/s, 46 seconds passed', '... 70%, 491520 KB, 10584 KB/s, 46 seconds passed', '... 70%, 492544 KB, 10603 KB/s, 46 seconds passed', '... 70%, 493568 KB, 10620 KB/s, 46 seconds passed', '... 71%, 494592 KB, 10639 KB/s, 46 seconds passed', '... 71%, 495616 KB, 10657 KB/s, 46 seconds passed', '... 71%, 496640 KB, 10676 KB/s, 46 seconds passed', '... 71%, 497664 KB, 10694 KB/s, 46 seconds passed', '... 71%, 498688 KB, 10713 KB/s, 46 seconds passed', '... 71%, 499712 KB, 10731 KB/s, 46 seconds passed', '... 71%, 500736 KB, 10749 KB/s, 46 seconds passed', '... 72%, 501760 KB, 10768 KB/s, 46 seconds passed', '... 72%, 502784 KB, 10785 KB/s, 46 seconds passed', '... 72%, 503808 KB, 10804 KB/s, 46 seconds passed', '... 72%, 504832 KB, 10823 KB/s, 46 seconds passed', '... 72%, 505856 KB, 10839 KB/s, 46 seconds passed', '... 72%, 506880 KB, 10858 KB/s, 46 seconds passed', '... 73%, 507904 KB, 10876 KB/s, 46 seconds passed', '... 73%, 508928 KB, 10894 KB/s, 46 seconds passed', '... 73%, 509952 KB, 10913 KB/s, 46 seconds passed', '... 73%, 510976 KB, 10931 KB/s, 46 seconds passed', '... 73%, 512000 KB, 10949 KB/s, 46 seconds passed', '... 73%, 513024 KB, 10968 KB/s, 46 seconds passed', '... 73%, 514048 KB, 10986 KB/s, 46 seconds passed', '... 74%, 515072 KB, 11005 KB/s, 46 seconds passed', '... 74%, 516096 KB, 11023 KB/s, 46 seconds passed', '... 74%, 517120 KB, 11041 KB/s, 46 seconds passed', '... 74%, 518144 KB, 11060 KB/s, 46 seconds passed', '... 74%, 519168 KB, 11078 KB/s, 46 seconds passed', '... 74%, 520192 KB, 11097 KB/s, 46 seconds passed', '... 74%, 521216 KB, 11115 KB/s, 46 seconds passed', '... 75%, 522240 KB, 11129 KB/s, 46 seconds passed', '... 75%, 523264 KB, 11149 KB/s, 46 seconds passed', '... 75%, 524288 KB, 11169 KB/s, 46 seconds passed', '... 75%, 525312 KB, 11184 KB/s, 46 seconds passed', '... 75%, 526336 KB, 11204 KB/s, 46 seconds passed', '... 75%, 527360 KB, 11214 KB/s, 47 seconds passed', '... 75%, 528384 KB, 11232 KB/s, 47 seconds passed', '... 76%, 529408 KB, 11251 KB/s, 47 seconds passed', '... 76%, 530432 KB, 11268 KB/s, 47 seconds passed', '... 76%, 531456 KB, 11287 KB/s, 47 seconds passed', '... 76%, 532480 KB, 11291 KB/s, 47 seconds passed', '... 76%, 533504 KB, 11310 KB/s, 47 seconds passed', '... 76%, 534528 KB, 11328 KB/s, 47 seconds passed', '... 77%, 535552 KB, 11346 KB/s, 47 seconds passed', '... 77%, 536576 KB, 11365 KB/s, 47 seconds passed', '... 77%, 537600 KB, 11371 KB/s, 47 seconds passed', '... 77%, 538624 KB, 11390 KB/s, 47 seconds passed', '... 77%, 539648 KB, 11410 KB/s, 47 seconds passed', '... 77%, 540672 KB, 11426 KB/s, 47 seconds passed', '... 77%, 541696 KB, 11445 KB/s, 47 seconds passed', '... 78%, 542720 KB, 11461 KB/s, 47 seconds passed', '... 78%, 543744 KB, 11480 KB/s, 47 seconds passed', '... 78%, 544768 KB, 11499 KB/s, 47 seconds passed', '... 78%, 545792 KB, 11516 KB/s, 47 seconds passed', '... 78%, 546816 KB, 11534 KB/s, 47 seconds passed', '... 78%, 547840 KB, 11534 KB/s, 47 seconds passed', '... 78%, 548864 KB, 11552 KB/s, 47 seconds passed', '... 79%, 549888 KB, 11571 KB/s, 47 seconds passed', '... 79%, 550912 KB, 11588 KB/s, 47 seconds passed', '... 79%, 551936 KB, 11607 KB/s, 47 seconds passed', '... 79%, 552960 KB, 11604 KB/s, 47 seconds passed', '... 79%, 553984 KB, 11617 KB/s, 47 seconds passed', '... 79%, 555008 KB, 11635 KB/s, 47 seconds passed', '... 79%, 556032 KB, 11654 KB/s, 47 seconds passed', '... 80%, 557056 KB, 11670 KB/s, 47 seconds passed', '... 80%, 558080 KB, 11688 KB/s, 47 seconds passed', '... 80%, 559104 KB, 11704 KB/s, 47 seconds passed', '... 80%, 560128 KB, 11722 KB/s, 47 seconds passed', '... 80%, 561152 KB, 11739 KB/s, 47 seconds passed', '... 80%, 562176 KB, 11757 KB/s, 47 seconds passed', '... 80%, 563200 KB, 11776 KB/s, 47 seconds passed', '... 81%, 564224 KB, 11793 KB/s, 47 seconds passed', '... 81%, 565248 KB, 11811 KB/s, 47 seconds passed', '... 81%, 566272 KB, 11830 KB/s, 47 seconds passed', '... 81%, 567296 KB, 11847 KB/s, 47 seconds passed', '... 81%, 568320 KB, 11849 KB/s, 47 seconds passed', '... 81%, 569344 KB, 11866 KB/s, 47 seconds passed', '... 82%, 570368 KB, 11885 KB/s, 47 seconds passed', '... 82%, 571392 KB, 11895 KB/s, 48 seconds passed', '... 82%, 572416 KB, 11914 KB/s, 48 seconds passed', '... 82%, 573440 KB, 11921 KB/s, 48 seconds passed', '... 82%, 574464 KB, 11939 KB/s, 48 seconds passed', '... 82%, 575488 KB, 11953 KB/s, 48 seconds passed', '... 82%, 576512 KB, 11966 KB/s, 48 seconds passed', '... 83%, 577536 KB, 11981 KB/s, 48 seconds passed', '... 83%, 578560 KB, 11994 KB/s, 48 seconds passed', '... 83%, 579584 KB, 12008 KB/s, 48 seconds passed', '... 83%, 580608 KB, 12023 KB/s, 48 seconds passed', '... 83%, 581632 KB, 12038 KB/s, 48 seconds passed', '... 83%, 582656 KB, 12052 KB/s, 48 seconds passed', '... 83%, 583680 KB, 12068 KB/s, 48 seconds passed', '... 84%, 584704 KB, 12083 KB/s, 48 seconds passed', '... 84%, 585728 KB, 12098 KB/s, 48 seconds passed', '... 84%, 586752 KB, 12112 KB/s, 48 seconds passed', '... 84%, 587776 KB, 12128 KB/s, 48 seconds passed', '... 84%, 588800 KB, 12143 KB/s, 48 seconds passed', '... 84%, 589824 KB, 12158 KB/s, 48 seconds passed', '... 84%, 590848 KB, 12172 KB/s, 48 seconds passed', '... 85%, 591872 KB, 12188 KB/s, 48 seconds passed', '... 85%, 592896 KB, 12202 KB/s, 48 seconds passed', '... 85%, 593920 KB, 12216 KB/s, 48 seconds passed', '... 85%, 594944 KB, 12231 KB/s, 48 seconds passed', '... 85%, 595968 KB, 12247 KB/s, 48 seconds passed', '... 85%, 596992 KB, 12261 KB/s, 48 seconds passed', '... 85%, 598016 KB, 12275 KB/s, 48 seconds passed', '... 86%, 599040 KB, 12291 KB/s, 48 seconds passed', '... 86%, 600064 KB, 12306 KB/s, 48 seconds passed', '... 86%, 601088 KB, 12320 KB/s, 48 seconds passed', '... 86%, 602112 KB, 12335 KB/s, 48 seconds passed', '... 86%, 603136 KB, 12350 KB/s, 48 seconds passed', '... 86%, 604160 KB, 12365 KB/s, 48 seconds passed', '... 87%, 605184 KB, 12379 KB/s, 48 seconds passed', '... 87%, 606208 KB, 12394 KB/s, 48 seconds passed', '... 87%, 607232 KB, 12409 KB/s, 48 seconds passed', '... 87%, 608256 KB, 12423 KB/s, 48 seconds passed', '... 87%, 609280 KB, 12438 KB/s, 48 seconds passed', '... 87%, 610304 KB, 12452 KB/s, 49 seconds passed', '... 87%, 611328 KB, 12468 KB/s, 49 seconds passed', '... 88%, 612352 KB, 12481 KB/s, 49 seconds passed', '... 88%, 613376 KB, 12496 KB/s, 49 seconds passed', '... 88%, 614400 KB, 12510 KB/s, 49 seconds passed', '... 88%, 615424 KB, 12526 KB/s, 49 seconds passed', '... 88%, 616448 KB, 12540 KB/s, 49 seconds passed', '... 88%, 617472 KB, 12554 KB/s, 49 seconds passed', '... 88%, 618496 KB, 12568 KB/s, 49 seconds passed', '... 89%, 619520 KB, 12578 KB/s, 49 seconds passed', '... 89%, 620544 KB, 12593 KB/s, 49 seconds passed', '... 89%, 621568 KB, 12601 KB/s, 49 seconds passed', '... 89%, 622592 KB, 12609 KB/s, 49 seconds passed', '... 89%, 623616 KB, 12618 KB/s, 49 seconds passed', '... 89%, 624640 KB, 12627 KB/s, 49 seconds passed', '... 89%, 625664 KB, 12634 KB/s, 49 seconds passed', '... 90%, 626688 KB, 12644 KB/s, 49 seconds passed', '... 90%, 627712 KB, 12650 KB/s, 49 seconds passed', '... 90%, 628736 KB, 12660 KB/s, 49 seconds passed', '... 90%, 629760 KB, 12670 KB/s, 49 seconds passed', '... 90%, 630784 KB, 12676 KB/s, 49 seconds passed', '... 90%, 631808 KB, 12686 KB/s, 49 seconds passed', '... 90%, 632832 KB, 12693 KB/s, 49 seconds passed', '... 91%, 633856 KB, 12703 KB/s, 49 seconds passed', '... 91%, 634880 KB, 12710 KB/s, 49 seconds passed', '... 91%, 635904 KB, 12719 KB/s, 49 seconds passed', '... 91%, 636928 KB, 12726 KB/s, 50 seconds passed', '... 91%, 637952 KB, 12736 KB/s, 50 seconds passed', '... 91%, 638976 KB, 12743 KB/s, 50 seconds passed', '... 92%, 640000 KB, 12751 KB/s, 50 seconds passed', '... 92%, 641024 KB, 12761 KB/s, 50 seconds passed', '... 92%, 642048 KB, 12770 KB/s, 50 seconds passed', '... 92%, 643072 KB, 12779 KB/s, 50 seconds passed', '... 92%, 644096 KB, 12787 KB/s, 50 seconds passed', '... 92%, 645120 KB, 12796 KB/s, 50 seconds passed', '... 92%, 646144 KB, 12804 KB/s, 50 seconds passed', '... 93%, 647168 KB, 12813 KB/s, 50 seconds passed', '... 93%, 648192 KB, 12820 KB/s, 50 seconds passed', '... 93%, 649216 KB, 12829 KB/s, 50 seconds passed', '... 93%, 650240 KB, 12835 KB/s, 50 seconds passed', '... 93%, 651264 KB, 12845 KB/s, 50 seconds passed', '... 93%, 652288 KB, 12853 KB/s, 50 seconds passed', '... 93%, 653312 KB, 12861 KB/s, 50 seconds passed', '... 94%, 654336 KB, 12870 KB/s, 50 seconds passed', '... 94%, 655360 KB, 12879 KB/s, 50 seconds passed', '... 94%, 656384 KB, 12887 KB/s, 50 seconds passed', '... 94%, 657408 KB, 12896 KB/s, 50 seconds passed', '... 94%, 658432 KB, 12904 KB/s, 51 seconds passed', '... 94%, 659456 KB, 12914 KB/s, 51 seconds passed', '... 94%, 660480 KB, 12923 KB/s, 51 seconds passed', '... 95%, 661504 KB, 12932 KB/s, 51 seconds passed', '... 95%, 662528 KB, 12941 KB/s, 51 seconds passed', '... 95%, 663552 KB, 12951 KB/s, 51 seconds passed', '... 95%, 664576 KB, 12960 KB/s, 51 seconds passed', '... 95%, 665600 KB, 12969 KB/s, 51 seconds passed', '... 95%, 666624 KB, 12979 KB/s, 51 seconds passed', '... 95%, 667648 KB, 12988 KB/s, 51 seconds passed', '... 96%, 668672 KB, 12996 KB/s, 51 seconds passed', '... 96%, 669696 KB, 13006 KB/s, 51 seconds passed', '... 96%, 670720 KB, 13015 KB/s, 51 seconds passed', '... 96%, 671744 KB, 13026 KB/s, 51 seconds passed', '... 96%, 672768 KB, 13035 KB/s, 51 seconds passed', '... 96%, 673792 KB, 13045 KB/s, 51 seconds passed', '... 97%, 674816 KB, 13055 KB/s, 51 seconds passed', '... 97%, 675840 KB, 13064 KB/s, 51 seconds passed', '... 97%, 676864 KB, 13074 KB/s, 51 seconds passed', '... 97%, 677888 KB, 13084 KB/s, 51 seconds passed', '... 97%, 678912 KB, 13094 KB/s, 51 seconds passed', '... 97%, 679936 KB, 13104 KB/s, 51 seconds passed', '... 97%, 680960 KB, 13113 KB/s, 51 seconds passed', '... 98%, 681984 KB, 13123 KB/s, 51 seconds passed', '... 98%, 683008 KB, 13133 KB/s, 52 seconds passed', '... 98%, 684032 KB, 13143 KB/s, 52 seconds passed', '... 98%, 685056 KB, 13153 KB/s, 52 seconds passed', '... 98%, 686080 KB, 13163 KB/s, 52 seconds passed', '... 98%, 687104 KB, 13173 KB/s, 52 seconds passed', '... 98%, 688128 KB, 13183 KB/s, 52 seconds passed', '... 99%, 689152 KB, 13193 KB/s, 52 seconds passed', '... 99%, 690176 KB, 13203 KB/s, 52 seconds passed', '... 99%, 691200 KB, 13213 KB/s, 52 seconds passed', '... 99%, 692224 KB, 13223 KB/s, 52 seconds passed', '... 99%, 693248 KB, 13233 KB/s, 52 seconds passed', '... 99%, 694272 KB, 13243 KB/s, 52 seconds passed', '... 99%, 695296 KB, 13253 KB/s, 52 seconds passed', '... 100%, 695506 KB, 13256 KB/s, 52 seconds passed', '', '========== Downloading /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/addict-2.4.0-py3-none-any.whl', '... 100%, 3 KB, 3569 KB/s, 0 seconds passed', '', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/heads/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/sequences/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/component.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/decoders/bricks/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/backbones/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/bodies/feature_extractors/encoders/enhance_modules/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/models/utils/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/__init__.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Replacing text in /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/utils/config.py', '========== Unpacking /opt/home/k8sworker/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 /opt/home/k8sworker/open_model_zoo_models --output_dir /opt/home/k8sworker/open_model_zoo_models

Converting text-recognition-resnet-fc…

========== Converting text-recognition-resnet-fc to ONNX
Conversion to ONNX command: /opt/home/k8sworker/cibuilds/ov-notebook/OVNotebookOps-104/.workspace/scm/ov-notebook/.venv/bin/python -- /opt/home/k8sworker/cibuilds/ov-notebook/OVNotebookOps-104/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/model_zoo/internal_scripts/pytorch_to_onnx.py --model-path=/opt/home/k8sworker/cibuilds/ov-notebook/OVNotebookOps-104/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/model_zoo/models/public/text-recognition-resnet-fc --model-path=/opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc --model-name=get_model --import-module=model '--model-param=file_config=r"/opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/vedastr/configs/resnet_fc.py"' '--model-param=weights=r"/opt/home/k8sworker/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=/opt/home/k8sworker/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/home/k8sworker/cibuilds/ov-notebook/OVNotebookOps-104/.workspace/scm/ov-notebook/.venv/bin/python -- /opt/home/k8sworker/cibuilds/ov-notebook/OVNotebookOps-104/.workspace/scm/ov-notebook/.venv/bin/mo --framework=onnx --data_type=FP16 --output_dir=/opt/home/k8sworker/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=/opt/home/k8sworker/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:  /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/resnet_fc.onnx
    - Path for generated IR:    /opt/home/k8sworker/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/home/k8sworker/cibuilds/ov-notebook/OVNotebookOps-104/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino
OpenVINO runtime version:   2022.1.0-7009-19bdd019745-refs/pull/1012/head
Model Optimizer version:    2022.1.0-7009-19bdd019745-refs/pull/1012/head
[ SUCCESS ] Generated IR version 11 model.
[ SUCCESS ] XML file: /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/FP16/text-recognition-resnet-fc.xml
[ SUCCESS ] BIN file: /opt/home/k8sworker/open_model_zoo_models/public/text-recognition-resnet-fc/FP16/text-recognition-resnet-fc.bin
[ SUCCESS ] Total execution time: 3.94 seconds.
[ SUCCESS ] Memory consumed: 1443 MB.
[ 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
/opt/home/k8sworker/open_model_zoo_models/intel/horizontal-text-detection-0001/FP16
/opt/home/k8sworker/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 = next(iter(detection_compiled_model.inputs))

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].

request = detection_compiled_model.create_infer_request()
request.infer(inputs={detection_input_layer.any_name: input_image})
boxes = request.get_tensor("boxes").data

# 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 = next(iter(recognition_compiled_model.outputs))
recognition_input_layer = next(iter(recognition_compiled_model.inputs))

# 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
    request = recognition_compiled_model.create_infer_request()
    request.infer(inputs={recognition_input_layer.any_name: image_crop})
    result = request.get_output_tensor(recognition_output_layer.index).data

    # 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