mmocr/demo/MMOCR_Tutorial.ipynb

892 lines
992 KiB
Plaintext
Raw Normal View History

{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "mmocr.ipynb",
"provenance": [],
"collapsed_sections": [],
"toc_visible": true,
"authorship_tag": "ABX9TyME/exPK5rcfPnot26KkDkL",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.5"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/open-mmlab/mmocr/blob/main/demo/MMOCR_Tutorial.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "jU9T31gbQmvs"
},
"source": [
"# MMOCR Tutorial\n",
"\n",
"Welcome to MMOCR! This is the official colab tutorial for using MMOCR. In this tutorial, you will learn how to\n",
"\n",
"- Perform testing with a pretrained text recognizer.\n",
"- Perform testing with a pretrained Key Information Extraction (KIE) model.\n",
"- Perform testing with a pretrained text detector\n",
"- Train a text recognizer with a toy dataset.\n",
"\n",
"Let's start!"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Sfvz1sywQ9_4"
},
"source": [
"## Install MMOCR"
]
},
{
"source": [
"When installing dependencies for mmocr, please ensure that all the dependency versions are compatible with each other. For instance, if CUDA 10.1 is installed, then the Pytorch version must be compatible with cu10.1. Please see [getting_started.md](docs/getting_started.md) for more details. "
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/home/SENSETIME/lintsuihin/code/mmocr-1\n"
]
}
],
"source": [
"%cd .."
]
},
{
"source": [
"### Check NVCC and GCC compiler version"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "2DBpcKj2RDfu",
"outputId": "2e99d7ce-3858-4c05-ab29-847f58e1a92e"
},
"source": [
"!nvcc -V\n",
"!gcc --version"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"nvcc: NVIDIA (R) Cuda compiler driver\n",
"Copyright (c) 2005-2019 NVIDIA Corporation\n",
"Built on Sun_Jul_28_19:07:16_PDT_2019\n",
"Cuda compilation tools, release 10.1, V10.1.243\n",
"gcc (Ubuntu 6.5.0-2ubuntu1~16.04) 6.5.0 20181026\n",
"Copyright (C) 2017 Free Software Foundation, Inc.\n",
"This is free software; see the source for copying conditions. There is NO\n",
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
"\n"
]
}
]
},
{
"source": [
"### Install Dependencies "
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "DwDY3puNNmhe",
"outputId": "06e48bab-3a07-4449-e5ef-9884fe61fe63",
"tags": [
"outputPrepend"
]
},
"source": [
"# Install torch dependencies: (use cu101 since colab has CUDA 10.1)\n",
"!pip install -U torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html\n",
"\n",
"# Install mmcv-full thus we could use CUDA operators\n",
"!pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/index.html\n",
"\n",
"# Install mmdetection\n",
"!pip install mmdet==2.11.0\n",
"\n",
"# Install mmocr\n",
"!git clone https://github.com/open-mmlab/mmocr.git\n",
"!pip install -r requirements.txt\n",
"!pip install -v -e .\n",
"\n",
"# install Pillow 7.0.0 back in order to avoid bug in colab\n",
"!pip install Pillow==7.0.0"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"irement already satisfied: addict in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmcv-full) (2.4.0)\n",
"Requirement already satisfied: mmdet==2.11.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (2.11.0)\n",
"Requirement already satisfied: matplotlib in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmdet==2.11.0) (3.3.2)\n",
"Requirement already satisfied: mmpycocotools in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmdet==2.11.0) (12.0.3)\n",
"Requirement already satisfied: terminaltables in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmdet==2.11.0) (3.1.0)\n",
"Requirement already satisfied: numpy in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmdet==2.11.0) (1.19.2)\n",
"Requirement already satisfied: six in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmdet==2.11.0) (1.15.0)\n",
"Requirement already satisfied: cycler>=0.10 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmdet==2.11.0) (0.10.0)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmdet==2.11.0) (1.3.0)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmdet==2.11.0) (2.8.1)\n",
"Requirement already satisfied: pillow>=6.2.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmdet==2.11.0) (7.0.0)\n",
"Requirement already satisfied: certifi>=2020.06.20 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmdet==2.11.0) (2020.6.20)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmdet==2.11.0) (2.4.7)\n",
"Requirement already satisfied: cython>=0.27.3 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmpycocotools->mmdet==2.11.0) (0.29.21)\n",
"Requirement already satisfied: setuptools>=18.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmpycocotools->mmdet==2.11.0) (50.3.1.post20201107)\n",
"fatal: destination path 'mmocr' already exists and is not an empty directory.\n",
"Requirement already satisfied: numpy in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/build.txt (line 2)) (1.19.2)\n",
"Requirement already satisfied: Polygon3 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/build.txt (line 3)) (3.0.9.1)\n",
"Requirement already satisfied: pyclipper in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/build.txt (line 4)) (1.2.1)\n",
"Requirement already satisfied: torch>=1.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/build.txt (line 5)) (1.5.0+cu101)\n",
"Requirement already satisfied: imgaug in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 1)) (0.4.0)\n",
"Requirement already satisfied: lmdb in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 2)) (1.2.1)\n",
"Requirement already satisfied: matplotlib in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 3)) (3.3.2)\n",
"Requirement already satisfied: numba>=0.45.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 4)) (0.51.2)\n",
"Requirement already satisfied: rapidfuzz in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 6)) (1.4.1)\n",
"Requirement already satisfied: scikit-image in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 7)) (0.17.2)\n",
"Requirement already satisfied: six in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 8)) (1.15.0)\n",
"Requirement already satisfied: terminaltables in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/runtime.txt (line 9)) (3.1.0)\n",
"Requirement already satisfied: asynctest in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 1)) (0.13.0)\n",
"Requirement already satisfied: codecov in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 2)) (2.1.11)\n",
"Requirement already satisfied: flake8 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 3)) (3.8.4)\n",
"Requirement already satisfied: isort in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 4)) (5.6.4)\n",
"Requirement already satisfied: kwarray in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 6)) (0.5.19)\n",
"Requirement already satisfied: pytest in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 8)) (0.0.0)\n",
"Requirement already satisfied: pytest-cov in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 9)) (2.12.0)\n",
"Requirement already satisfied: pytest-runner in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 10)) (5.3.0)\n",
"Requirement already satisfied: ubelt in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 11)) (0.9.5)\n",
"Requirement already satisfied: xdoctest>=0.10.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 12)) (0.15.4)\n",
"Requirement already satisfied: yapf in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from -r requirements/tests.txt (line 13)) (0.30.0)\n",
"Requirement already satisfied: future in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from torch>=1.1->-r requirements/build.txt (line 5)) (0.18.2)\n",
"Requirement already satisfied: opencv-python in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->-r requirements/runtime.txt (line 1)) (4.5.2.52)\n",
"Requirement already satisfied: Pillow in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->-r requirements/runtime.txt (line 1)) (7.0.0)\n",
"Requirement already satisfied: imageio in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->-r requirements/runtime.txt (line 1)) (2.9.0)\n",
"Requirement already satisfied: Shapely in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->-r requirements/runtime.txt (line 1)) (1.7.1)\n",
"Requirement already satisfied: scipy in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->-r requirements/runtime.txt (line 1)) (1.5.2)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->-r requirements/runtime.txt (line 3)) (1.3.0)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->-r requirements/runtime.txt (line 3)) (2.4.7)\n",
"Requirement already satisfied: cycler>=0.10 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->-r requirements/runtime.txt (line 3)) (0.10.0)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->-r requirements/runtime.txt (line 3)) (2.8.1)\n",
"Requirement already satisfied: certifi>=2020.06.20 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->-r requirements/runtime.txt (line 3)) (2020.6.20)\n",
"Requirement already satisfied: setuptools in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from numba>=0.45.1->-r requirements/runtime.txt (line 4)) (50.3.1.post20201107)\n",
"Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from numba>=0.45.1->-r requirements/runtime.txt (line 4)) (0.34.0)\n",
"Requirement already satisfied: networkx>=2.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from scikit-image->-r requirements/runtime.txt (line 7)) (2.5)\n",
"Requirement already satisfied: tifffile>=2019.7.26 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from scikit-image->-r requirements/runtime.txt (line 7)) (2020.10.1)\n",
"Requirement already satisfied: PyWavelets>=1.1.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from scikit-image->-r requirements/runtime.txt (line 7)) (1.1.1)\n",
"Requirement already satisfied: coverage in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from codecov->-r requirements/tests.txt (line 2)) (5.5)\n",
"Requirement already satisfied: requests>=2.7.9 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from codecov->-r requirements/tests.txt (line 2)) (2.24.0)\n",
"Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from flake8->-r requirements/tests.txt (line 3)) (0.6.1)\n",
"Requirement already satisfied: pyflakes<2.3.0,>=2.2.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from flake8->-r requirements/tests.txt (line 3)) (2.2.0)\n",
"Requirement already satisfied: pycodestyle<2.7.0,>=2.6.0a1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from flake8->-r requirements/tests.txt (line 3)) (2.6.0)\n",
"Requirement already satisfied: attrs>=17.4.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from pytest->-r requirements/tests.txt (line 8)) (20.3.0)\n",
"Requirement already satisfied: iniconfig in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from pytest->-r requirements/tests.txt (line 8)) (1.1.1)\n",
"Requirement already satisfied: packaging in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from pytest->-r requirements/tests.txt (line 8)) (20.4)\n",
"Requirement already satisfied: pluggy<1.0,>=0.12 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from pytest->-r requirements/tests.txt (line 8)) (0.13.1)\n",
"Requirement already satisfied: py>=1.8.2 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from pytest->-r requirements/tests.txt (line 8)) (1.9.0)\n",
"Requirement already satisfied: toml in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from pytest->-r requirements/tests.txt (line 8)) (0.10.1)\n",
"Requirement already satisfied: ordered-set in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from ubelt->-r requirements/tests.txt (line 11)) (4.0.2)\n",
"Requirement already satisfied: decorator>=4.3.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from networkx>=2.0->scikit-image->-r requirements/runtime.txt (line 7)) (4.4.2)\n",
"Requirement already satisfied: idna<3,>=2.5 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (2.10)\n",
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (1.25.11)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (3.0.4)\n",
"Using pip 20.2.4 from /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages/pip (python 3.8)\n",
"Non-user install because site-packages writeable\n",
"Created temporary directory: /tmp/pip-ephem-wheel-cache-it9h88fb\n",
"Created temporary directory: /tmp/pip-req-tracker-08_a9ef2\n",
"Initialized build tracking at /tmp/pip-req-tracker-08_a9ef2\n",
"Created build tracker: /tmp/pip-req-tracker-08_a9ef2\n",
"Entered build tracker: /tmp/pip-req-tracker-08_a9ef2\n",
"Created temporary directory: /tmp/pip-install-fkw968jx\n",
"Obtaining file:///home/SENSETIME/lintsuihin/code/mmocr-1\n",
" Added file:///home/SENSETIME/lintsuihin/code/mmocr-1 to build tracker '/tmp/pip-req-tracker-08_a9ef2'\n",
" Running setup.py (path:/home/SENSETIME/lintsuihin/code/mmocr-1/setup.py) egg_info for package from file:///home/SENSETIME/lintsuihin/code/mmocr-1\n",
" Created temporary directory: /tmp/pip-pip-egg-info-v8c72ldk\n",
" Running command python setup.py egg_info\n",
" running egg_info\n",
" creating /tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info\n",
" writing /tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/PKG-INFO\n",
" writing dependency_links to /tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/dependency_links.txt\n",
" writing requirements to /tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/requires.txt\n",
" writing top-level names to /tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/top_level.txt\n",
" writing manifest file '/tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/SOURCES.txt'\n",
" reading manifest file '/tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/SOURCES.txt'\n",
" reading manifest template 'MANIFEST.in'\n",
" warning: no files found matching 'mmocr/model_zoo.yml'\n",
" warning: no files found matching '*.py' under directory 'mmocr/configs'\n",
" warning: no files found matching '*.yml' under directory 'mmocr/configs'\n",
" warning: no files found matching '*.sh' under directory 'mmocr/tools'\n",
" warning: no files found matching '*.py' under directory 'mmocr/tools'\n",
" writing manifest file '/tmp/pip-pip-egg-info-v8c72ldk/mmocr.egg-info/SOURCES.txt'\n",
" Source in /home/SENSETIME/lintsuihin/code/mmocr-1 has version 0.1.0, which satisfies requirement mmocr==0.1.0 from file:///home/SENSETIME/lintsuihin/code/mmocr-1\n",
" Removed mmocr==0.1.0 from file:///home/SENSETIME/lintsuihin/code/mmocr-1 from build tracker '/tmp/pip-req-tracker-08_a9ef2'\n",
"Requirement already satisfied: imgaug in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (0.4.0)\n",
"Requirement already satisfied: lmdb in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (1.2.1)\n",
"Requirement already satisfied: matplotlib in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (3.3.2)\n",
"Requirement already satisfied: numba>=0.45.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (0.51.2)\n",
"Requirement already satisfied: numpy in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (1.19.2)\n",
"Requirement already satisfied: rapidfuzz in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (1.4.1)\n",
"Requirement already satisfied: scikit-image in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (0.17.2)\n",
"Requirement already satisfied: six in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (1.15.0)\n",
"Requirement already satisfied: terminaltables in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from mmocr==0.1.0) (3.1.0)\n",
"Requirement already satisfied: imageio in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->mmocr==0.1.0) (2.9.0)\n",
"Requirement already satisfied: opencv-python in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->mmocr==0.1.0) (4.5.2.52)\n",
"Requirement already satisfied: Pillow in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->mmocr==0.1.0) (7.0.0)\n",
"Requirement already satisfied: scipy in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->mmocr==0.1.0) (1.5.2)\n",
"Requirement already satisfied: Shapely in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from imgaug->mmocr==0.1.0) (1.7.1)\n",
"Requirement already satisfied: cycler>=0.10 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmocr==0.1.0) (0.10.0)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmocr==0.1.0) (2.4.7)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmocr==0.1.0) (2.8.1)\n",
"Requirement already satisfied: certifi>=2020.06.20 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmocr==0.1.0) (2020.6.20)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from matplotlib->mmocr==0.1.0) (1.3.0)\n",
"Requirement already satisfied: setuptools in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from numba>=0.45.1->mmocr==0.1.0) (50.3.1.post20201107)\n",
"Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from numba>=0.45.1->mmocr==0.1.0) (0.34.0)\n",
"Requirement already satisfied: networkx>=2.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from scikit-image->mmocr==0.1.0) (2.5)\n",
"Requirement already satisfied: tifffile>=2019.7.26 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from scikit-image->mmocr==0.1.0) (2020.10.1)\n",
"Requirement already satisfied: PyWavelets>=1.1.1 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from scikit-image->mmocr==0.1.0) (1.1.1)\n",
"Requirement already satisfied: decorator>=4.3.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (from networkx>=2.0->scikit-image->mmocr==0.1.0) (4.4.2)\n",
"Installing collected packages: mmocr\n",
" Attempting uninstall: mmocr\n",
" Found existing installation: mmocr 0.1.0\n",
" Uninstalling mmocr-0.1.0:\n",
" Created temporary directory: /tmp/pip-uninstall-33pibh4i\n",
" Removing file or directory /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages/mmocr.egg-link\n",
" Removing pth entries from /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages/easy-install.pth:\n",
" Removing entry: /home/SENSETIME/lintsuihin/code/mmocr-1\n",
" Successfully uninstalled mmocr-0.1.0\n",
" Running setup.py develop for mmocr\n",
" Running command /home/SENSETIME/lintsuihin/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'/home/SENSETIME/lintsuihin/code/mmocr-1/setup.py'\"'\"'; __file__='\"'\"'/home/SENSETIME/lintsuihin/code/mmocr-1/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' develop --no-deps\n",
" running develop\n",
" running egg_info\n",
" writing mmocr.egg-info/PKG-INFO\n",
" writing dependency_links to mmocr.egg-info/dependency_links.txt\n",
" writing requirements to mmocr.egg-info/requires.txt\n",
" writing top-level names to mmocr.egg-info/top_level.txt\n",
" reading manifest file 'mmocr.egg-info/SOURCES.txt'\n",
" reading manifest template 'MANIFEST.in'\n",
" warning: no files found matching 'mmocr/model_zoo.yml'\n",
" warning: no files found matching '*.py' under directory 'mmocr/configs'\n",
" warning: no files found matching '*.yml' under directory 'mmocr/configs'\n",
" warning: no files found matching '*.sh' under directory 'mmocr/tools'\n",
" warning: no files found matching '*.py' under directory 'mmocr/tools'\n",
" writing manifest file 'mmocr.egg-info/SOURCES.txt'\n",
" running build_ext\n",
" Creating /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages/mmocr.egg-link (link to .)\n",
" Adding mmocr 0.1.0 to easy-install.pth file\n",
"\n",
" Installed /home/SENSETIME/lintsuihin/code/mmocr-1\n",
"Successfully installed mmocr\n",
"Removed build tracker: '/tmp/pip-req-tracker-08_a9ef2'\n",
"Requirement already satisfied: Pillow==7.0.0 in /home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages (7.0.0)\n"
]
}
]
},
{
"source": [
"### Check Installed Dependencies Versions"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "JABQfPwQN52g",
"outputId": "d4c337c7-5b72-498d-bfd0-2955a3678c71"
},
"source": [
"# Check Pytorch installation\n",
"import torch, torchvision\n",
"print(torch.__version__, torch.cuda.is_available())\n",
"\n",
"# Check MMDetection installation\n",
"import mmdet\n",
"print(mmdet.__version__)\n",
"\n",
"# Check mmcv installation\n",
"import mmcv\n",
"from mmcv.ops import get_compiling_cuda_version, get_compiler_version\n",
"print(mmcv.__version__)\n",
"print(get_compiling_cuda_version())\n",
"print(get_compiler_version())\n",
"\n",
"# Check mmocr installation\n",
"import mmocr\n",
"print(mmocr.__version__)"
],
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"1.5.0+cu101 True\n2.11.0\n1.3.4\n10.1\nGCC 7.3\n0.1.0\n"
]
}
]
},
{
"source": [
"## Perform Testing with a Pretrained Text Recognizer \n",
"\n",
"We now demonstrate how to perform testing on a [demo text recognition image](demo/demo_text_recog.jpg) with a pretrained text recognizer. SAR text recognizer is used for this demo, whose checkpoint can be downloaded from the [official documentation](https://mmocr.readthedocs.io/en/latest/textrecog_models.html#show-attend-and-read-a-simple-and-strong-baseline-for-irregular-text-recognition). We visualize the predicted result in the end. "
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Use load_from_http loader\n",
"/home/SENSETIME/lintsuihin/anaconda3/lib/python3.8/site-packages/mmdet/apis/inference.py:47: UserWarning: Class names are not saved in the checkpoint's meta data, use COCO classes by default.\n",
" warnings.warn('Class names are not saved in the checkpoint\\'s '\n",
"result: {'text': 'STAR', 'score': 0.9664110988378525}\n"
]
}
],
"source": [
"!python demo/image_demo.py demo/demo_text_recog.jpg configs/textrecog/sar/sar_r31_parallel_decoder_academic.py https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth outputs/demo_text_recog_pred.jpg"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"251.467969pt\" version=\"1.1\" viewBox=\"0 0 162.7975 251.467969\" width=\"162.7975pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-17T11:37:26.897487</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M -0 251.467969 \nL 162.7975 251.467969 \nL 162.7975 0 \nL -0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 227.589844 \nL 155.5975 227.589844 \nL 155.5975 10.149844 \nL 33.2875 10.149844 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g clip-path=\"url(#p901284e575)\">\n <image height=\"218\" id=\"imageb892818520\" transform=\"scale(1 -1)translate(0 -218)\" width=\"123\" x=\"33.2875\" xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAHsAAADaCAYAAACGhz00AACJ8ElEQVR4nOz9d7QlSX7QiX/CZF7z7vOvvK9qU+39tBk/0ozGyxtkjoAfgkWLAEksrH6Y5aBdDgL9hPgtAgkhEBJIgpGY0Rj1aLzvnvbTvrq6urx9Vc/dd11mRsTvj4jIzPvqdU8L2D17fjNZ59Z7L2+aiPjG1zvxof/4vzrnwFnBxbNLXL60whOPP8VolDE9PUuz1abZapONLEpp9h88wMrKCq+88jKtlqLZVOzfN09nosHUVBNXOJxxSJXS7fb5wuceYjjKyAvL9Ow0zWaTwoyYnGyxf/8ulE6QUrG8PGR5ZZ0nv/ECSqekzQkK6yisYzjMsM5ibAFCIKSk3e4Akt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JVMajFdE3Gm3uBcvUZrdJjX/ZffYfqqK6EeA17D/sDP/xxHvvxlrjt9mol+n5lOF+UEDdSjGC3gkowIR4QQkQJCJmAV9CMNJka0IUstGYpuFNGu1ejU6hwZHaF26R7e/Pt/QDw+AfVaIT8WdnsUqpdgF9vc+yM/TOvhB2m2W3SaQ7TGRrjtl/4tm17xChgbw5kIF9VQSgXkzxl1/hNEBxFotznx0Y/y0L/6V0yfm2W03WFSxUQCWixWOax2uICIkRnCWkeW2dJ05RwGRcNEdMXRRZgbGWGpXufY+Ah7vuNd3PDud0MUg9bo0fH7ROSm5TjwoiiiUioG3gf8qYi8P1w+pZTaFKjhJuD0c+stn6RckwyTFRQPJeJZsbXQ77G0bx9nPvYxal9/gK2LbSb7PWIn1JSmZxR9Y8iMp0DoyCsPTmhkGZETTKAY4/0MbWHEKU7/6V/Q2XsFW9717eihBsQ1rvrmN7Bp+zbm/viPyObnEQQt/t46mkiEGEXNWepiqVuFFiEzip4xLNRq9E1EpgwqNlhl6EY1luKIpVrMrrd9OxNXXYlpDIHJlZigCORKmgTTirPEacJwkjCTWfqdDqNpwtn3v4/24/vY+cM/jBmfQEe5zKjKqS14aWCP4sBpdAaNbkLTwbAyOKXoa0WmDX0tJAYyo3BKgYsKdM5Vx8haIgfDIv6ZIgynCZGzJDi6d
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"# Visualize the results\n",
"import matplotlib.pyplot as plt\n",
"predicted_img = mmcv.imread('./outputs/demo_text_recog_pred.jpg')\n",
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "NgoH6qEcC9CL"
},
"source": [
"## Perform Testing with a Pretrained Text Detector \n",
"\n",
"Next, we perform testing with a pretrained PANet text detector and visualize the bounding box results for the demo text detection image provided in [demo_text_det.jpg](.github/demo/demo_text_det.jpg). The PANet checkpoint can be downloaded from the [official documentation](https://mmocr.readthedocs.io/en/latest/textdet_models.html#efficient-and-accurate-arbitrary-shaped-text-detection-with-pixel-aggregation-network)."
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "u0YyG9y0TzL4",
"outputId": "7c2199ca-0542-414d-a8cd-ab5998739c70"
},
"source": [
"!python demo/image_demo.py demo/demo_text_det.jpg configs/textdet/panet/panet_r18_fpem_ffm_600e_icdar2015.py https://download.openmmlab.com/mmocr/textdet/panet/panet_r18_fpem_ffm_sbn_600e_icdar2015_20210219-42dbe46a.pth outputs/demo_text_det_pred.jpg"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Use load_from_http loader\n",
"result: {'boundary_result': [[814.189567565918, 0.0, 904.2201447486877, 0.0, 904.2201447486877, 39.13043260574341, 814.189567565918, 39.13043260574341, 0.9057406783103943], [90.03057718276978, 46.95651912689209, 125.25993347167969, 46.95651912689209, 125.25993347167969, 70.43477869033813, 90.03057718276978, 70.43477869033813, 0.9709924459457397], [487.5236017727184, 85.64961081325555, 489.66499120697335, 57.820967069855215, 549.8311834401829, 62.44756185349934, 547.689794005928, 90.27620559689967, 0.9715930223464966], [364.0366816520691, 86.0869517326355, 395.351665019989, 86.0869517326355, 395.351665019989, 105.6521680355072, 364.0366816520691, 105.6521680355072, 0.9470174908638], [788.5383478123913, 153.76874482916082, 792.2102226550851, 98.70912997889491, 913.0188231752618, 106.76030933393577, 909.346948332568, 161.81991672066397, 0.9761190414428711], [913.193170931554, 163.02339724984085, 919.9379623092682, 109.08360413452465, 1040.3801876540092, 124.1337682248759, 1033.635396276295, 178.0735613401921, 0.9779257774353027], [352.2935628890991, 136.95651412010193, 411.009156703949, 136.95651412010193, 411.009156703949, 164.34781694412231, 352.2935628890991, 164.34781694412231, 0.9869399666786194], [775.2246657566138, 275.3233084723379, 779.3376959703164, 217.75984838066324, 999.3771074152028, 233.47161030806274, 995.2640772015002, 291.0350703997374, 0.9689262509346008], [776.844266222397, 337.47353044688134, 780.0181240757229, 318.4370908639139, 846.0335073331953, 329.4358974127899, 842.8596494798694, 348.47233699575736, 0.8988074064254761], [845.5045509338379, 332.60867714881897, 908.1345176696777, 332.60867714881897, 908.1345176696777, 352.1738934516907, 845.5045509338379, 352.1738934516907, 0.9521734118461609], [912.0488905906677, 356.086936712265, 912.0488905906677, 336.5217204093933, 951.1926198005676, 336.5217204093933, 951.1926198005676, 356.086936712265, 0.935749888420105], [951.1926198005676, 336.5217204093933, 1005.9938406944275, 336.5217204093933, 1005.9938406944275, 356.086936712265, 951.1926198005676, 356.086936712265, 0.8870333433151245], [773.9879255573032, 358.5193633612962, 777.0559443478851, 340.11750360885526, 828.4717487201124, 348.68391336285094, 825.4037299295305, 367.0857731152919, 0.9176182150840759], [825.8518138170621, 368.79755041688804, 827.5255283860315, 348.71961892727086, 921.4704784897913, 356.54570544841954, 919.7967639208218, 376.6236369380367, 0.9525177478790283], [919.8776364326477, 359.99997997283936, 1009.9082136154175, 359.99997997283936, 1009.9082136154175, 375.6521530151367, 919.8776364326477, 375.6521530151367, 0.8734318614006042], [803.7422605784741, 454.021000690258, 806.4688707445384, 421.31333039067795, 891.0193497293585, 428.3568202013721, 888.2927395632942, 461.06449050095216, 0.9488940238952637], [892.4770259857178, 430.4347586631775, 951.1926198005676, 430.4347586631775, 951.1926198005676, 461.7391047477722, 892.4770259857178, 461.7391047477722, 0.9485362768173218]]}\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 616
},
"id": "2-UHsqkZJFND",
"outputId": "e347af9e-2f92-45d5-d9c7-eb82802819cf"
},
"source": [
"# Visualize the results\n",
"import matplotlib.pyplot as plt\n",
"predicted_img = mmcv.imread('./outputs/demo_text_det_pred.jpg')\n",
"plt.figure(figsize=(9, 16))\n",
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
],
"execution_count": 7,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 648x1152 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"317.168672pt\" version=\"1.1\" viewBox=\"0 0 542.6875 317.168672\" width=\"542.6875pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-17T11:37:43.114613</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 317.168672 \nL 542.6875 317.168672 \nL 542.6875 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 293.290547 \nL 535.4875 293.290547 \nL 535.4875 10.803047 \nL 33.2875 10.803047 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g clip-path=\"url(#pd0aa5dfd1b)\">\n <image height=\"283\" id=\"image177a48ae17\" transform=\"scale(1 -1)translate(0 -283)\" width=\"503\" x=\"33.2875\" xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAfcAAAEbCAYAAADH883eAAEAAElEQVR4nOz9S49sSZImBn6iqu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
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "PTWMzvd3E_h8"
},
"source": [
"## Perform Testing with a Pretrained KIE Model\n",
"\n",
"We perform testing on the WildReceipt dataset for KIE model by first downloading the .tar file from [Datasets Preparation](https://mmocr.readthedocs.io/en/latest/datasets.html) in MMOCR documentation and then extract the dataset. We have chosen the Visual + Textual moduality test dataset, which we evaluate with Macro F1 metrics."
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "3VEW3PQrFZ0g",
"outputId": "885a4d2e-ca78-42ab-f4a2-dddd9a2d8321"
},
"source": [
"# First download the KIE dataset .tar file and extract it to ./data\n",
"!mkdir data\n",
"!wget https://download.openmmlab.com/mmocr/data/wildreceipt.tar\n",
"!tar -xf wildreceipt.tar \n",
"!mv wildreceipt ./data"
],
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"--2021-05-17 11:39:10-- https://download.openmmlab.com/mmocr/data/wildreceipt.tar\n",
"Resolving download.openmmlab.com (download.openmmlab.com)... 47.75.20.25\n",
"Connecting to download.openmmlab.com (download.openmmlab.com)|47.75.20.25|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 185323520 (177M) [application/x-tar]\n",
"Saving to: wildreceipt.tar.3\n",
"\n",
"wildreceipt.tar.3 100%[===================>] 176.74M 17.7MB/s in 10s \n",
"\n",
"2021-05-17 11:39:21 (17.1 MB/s) - wildreceipt.tar.3 saved [185323520/185323520]\n",
"\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "p0MHNwybo0iI",
"outputId": "4766b69e-04ea-4739-a0d1-9366789c0d91"
},
"source": [
"# Test the dataset with macro f1 metrics \n",
"!python tools/test.py configs/kie/sdmgr/sdmgr_unet16_60e_wildreceipt.py https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210405-16a47642.pth --eval macro_f1"
],
"execution_count": 12,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Use load_from_http loader\n",
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 472/472, 21.3 task/s, elapsed: 22s, ETA: 0s{'macro_f1': 0.87641114}\n"
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nYon41X7RTOT"
},
"source": [
"## Perform Training on a Toy Dataset with MMOCR Recognizer\n",
"We now demonstrate how to perform training with an MMOCR recognizer. Since training a full academic dataset is time consuming (usually takes about several hours), we will train on the toy dataset for the SAR text recognition model and visualize the predictions. Text detection and other downstream tasks such as KIE follow similar procedures.\n",
"\n",
"Training a dataset usually consists of the following steps:\n",
"1. Convert the dataset into a format supported by MMOCR (e.g. COCO for text detection). The annotation file can be in either .txt or .lmdb format, depending on the size of the dataset. This step is usually applicable to customized datasets, since the datasets and annotation files we provide are already in supported formats. \n",
"2. Modify the config for training. \n",
"3. Train the model. \n",
"\n",
"The toy dataset consisits of ten images as well as annotation files in both txt and lmdb format, which can be found in [ocr_toy_dataset](.github/tests/data/ocr_toy_dataset). "
]
},
{
"source": [
"### Visualize the Toy Dataset\n",
"\n",
"We first get a sense of what the toy dataset looks like by visualizing one of the images and labels. "
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 121
},
"id": "hZfd2pnqN5-Q",
"outputId": "9767e836-ccab-4a57-aa1a-1bbca56c430f"
},
"source": [
"import mmcv\n",
"import matplotlib.pyplot as plt \n",
"\n",
"img = mmcv.imread('./tests/data/ocr_toy_dataset/imgs/1036169.jpg')\n",
"plt.imshow(mmcv.bgr2rgb(img))\n",
"plt.show()"
],
"execution_count": 13,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"103.806756pt\" version=\"1.1\" viewBox=\"0 0 368.925 103.806756\" width=\"368.925pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-17T18:49:04.140634</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M -0 103.806756 \nL 368.925 103.806756 \nL 368.925 0 \nL -0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 26.925 79.928631 \nL 361.725 79.928631 \nL 361.725 9.592496 \nL 26.925 9.592496 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g clip-path=\"url(#p92dc6e7987)\">\n <image height=\"71\" id=\"image08a721bf03\" transform=\"scale(1 -1)translate(0 -71)\" width=\"335\" x=\"26.925\" xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAU8AAABHCAYAAACH6cUrAACyPUlEQVR4nMT9Z7NtWXaeiT3TLbPdsddm5k1TWZVlUYUCAaEhsTvIVnSH9Ev0Qb9Df0iKUJAR3RFkNx2IYhFAoVz6zJvXH7vNMtPpw5hr75MFqMmOpl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IbYRmuSIwwZPgmBPHUYkr46PHZONmioiwKAAKROAxy3mzIjTFYZ3M4rrNxksWVspEfhp4YPFqLh6q1QWnQ4gSDiqQoc2M04vtrRuaTcwXOufy7e95LhhSMNSjEgscQiSGMawKf56W2Nht7g7V2/zxSyttGEAMnG0e4FzmOPqAi7eERWR8kUDqJ35MgeU8aEikbw5jy5qU01loC2UNMiZhiNkJgkkFj5F6UlghGa6x1skGqvNGE/AT2nrnDGpvnGQxDzN6nOD8hJoL3hChrYYzEUjQy79IYKcmzGAZP27bAGEWBtZaicBijccbhyhKUog87Yhzy5jvaAYVKCp0UKY6bxZ0TvDfeI5w3Pt002pQc0SiFVhBSIgYx4to4XFmAUuLU5WguxXGTSPtnq/Jmr5RGW422BpQ4gT5fU4gKPBhtcE6e9S87/joG/A+Aryql3gY+A/6XwP/ql31AIYNbuJKyKNFK41yJNZYU5WlJuCUG2eSw8D4upVIk3duV9l74HpcDvR+Vuz/lfSOuqRG34V4QsfcQZe/UOn9HGrFU7jyRRIZjklxLPq91lqIoZCIMA0EFrHEURSkQRNfJxI+BECQcN1oT8j2Tv9cIioTRAQw5PI7iFyXxpFSSBWb3GHJ2FvLkiTHmRab2WOX9kGnvaaeUjaq6h+Wxf04xJrpONpoQAloZrDYkV6C1IoVASCF7fipj71E8DS2BvMre6+e9+/vfw/67R086RAiClOxfd057hhuygQtxXHL3vFMlkZDKhicq2aRQY/4kEqIHzD7aG93e+x74zz00ecv4TLXez5Ofv7fxvvQ4OVMiJX0v+sle+ogha4XSd+O1P1XMz0alHIn+3Djmn/ZPII+/QGVyknF8RgMfYxRvVQFKy3MhkZLaX994+3c3lO8J8Yy1MnlTS/vIZFwjKt8PxH3O6v4aTtmoyTXFu++85xXvv
},
"metadata": {
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "F5M_FVVRN6Fw",
"outputId": "e4ee7608-2bf9-4ae6-be00-691bdbef8c7c"
},
"source": [
"# Inspect the labels of the annootation file\n",
"!cat tests/data/ocr_toy_dataset/label.txt"
],
"execution_count": 14,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"1223731.jpg GRAND\n1223733.jpg HOTEL\n1223732.jpg HOTEL\n1223729.jpg PACIFIC\n1036169.jpg 03/09/2009\n1190237.jpg ANING\n1058891.jpg Virgin\n1058892.jpg america\n1240078.jpg ATTACK\n1210236.jpg DAVIDSON\n"
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "i-GrV0xSkAc3"
},
"source": [
"### Modify the Configuration File\n",
"\n",
"In order to perform inference for SAR on colab, we need to modify the config file to accommodate some of the settings of colab such as the number of GPU available. "
]
},
{
"cell_type": "code",
"metadata": {
"id": "uFFH3yUgPEFj"
},
"source": [
"from mmcv import Config\n",
"cfg = Config.fromfile('./configs/textrecog/sar/sar_r31_parallel_decoder_toy_dataset.py')"
],
"execution_count": 8,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "67OJ6oAvN6NA",
"outputId": "91253215-1117-4b8d-912d-b5eb6c6e3c2c"
},
"source": [
"from mmdet.apis import set_random_seed\n",
"\n",
"# Set up working dir to save files and logs.\n",
"cfg.work_dir = './demo/tutorial_exps'\n",
"\n",
"# The original learning rate (LR) is set for 8-GPU training.\n",
"# We divide it by 8 since we only use one GPU.\n",
"cfg.optimizer.lr = 0.001 / 8\n",
"cfg.lr_config.warmup = None\n",
"# Choose to log training results every 40 images to reduce the size of log file. \n",
"cfg.log_config.interval = 40\n",
"\n",
"# Set seed thus the results are more reproducible\n",
"cfg.seed = 0\n",
"set_random_seed(0, deterministic=False)\n",
"cfg.gpu_ids = range(1)\n",
"\n",
"# We can initialize the logger for training and have a look\n",
"# at the final config used for training\n",
"print(f'Config:\\n{cfg.pretty_text}')"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Config:\ncheckpoint_config = dict(interval=1)\nlog_config = dict(interval=40, hooks=[dict(type='TextLoggerHook')])\ndist_params = dict(backend='nccl')\nlog_level = 'INFO'\nload_from = None\nresume_from = None\nworkflow = [('train', 1)]\nlabel_convertor = dict(\n type='AttnConvertor', dict_type='DICT90', with_unknown=True)\nmodel = dict(\n type='SARNet',\n backbone=dict(type='ResNet31OCR'),\n encoder=dict(\n type='SAREncoder', enc_bi_rnn=False, enc_do_rnn=0.1, enc_gru=False),\n decoder=dict(\n type='ParallelSARDecoder',\n enc_bi_rnn=False,\n dec_bi_rnn=False,\n dec_do_rnn=0,\n dec_gru=False,\n pred_dropout=0.1,\n d_k=512,\n pred_concat=True),\n loss=dict(type='SARLoss'),\n label_convertor=dict(\n type='AttnConvertor', dict_type='DICT90', with_unknown=True),\n max_seq_len=30)\noptimizer = dict(type='Adam', lr=0.000125)\noptimizer_config = dict(grad_clip=None)\nlr_config = dict(policy='step', step=[3, 4], warmup=None)\ntotal_epochs = 5\nimg_norm_cfg = dict(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])\ntrain_pipeline = [\n dict(type='LoadImageFromFile'),\n dict(\n type='ResizeOCR',\n height=48,\n min_width=48,\n max_width=160,\n keep_aspect_ratio=True),\n dict(type='ToTensorOCR'),\n dict(type='NormalizeOCR', mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),\n dict(\n type='Collect',\n keys=['img'],\n meta_keys=[\n 'filename', 'ori_shape', 'img_shape', 'text', 'valid_ratio'\n ])\n]\ntest_pipeline = [\n dict(type='LoadImageFromFile'),\n dict(\n type='MultiRotateAugOCR',\n rotate_degrees=[0, 90, 270],\n transforms=[\n dict(\n type='ResizeOCR',\n height=48,\n min_width=48,\n max_width=160,\n keep_aspect_ratio=True),\n dict(type='ToTensorOCR'),\n dict(\n type='NormalizeOCR', mean=[0.5, 0.5, 0.5], std=[0.5, 0.5,\n 0.5]),\n dict(\n type='Collect',\n keys=['img'],\n meta_keys=[\n 'filename', 'ori_shape', 'img_shape', 'valid_ratio',\n 'img_norm_cfg', 'ori_filename'\n ])\n ])\n]\ndataset_type = 'OCRDataset'\nimg_prefix = 'tests/data/ocr_toy_dataset/imgs'\ntrain_anno_file1 = 'tests/data/ocr_toy_dataset/label.txt'\ntrain1 = dict(\n type='OCRDataset',\n img_prefix='tests/data/ocr_toy_dataset/imgs',\n ann_file='tests/data/ocr_toy_dataset/label.txt',\n loader=dict(\n type='HardDiskLoader',\n repeat=100,\n parser=dict(\n type='LineStrParser',\n keys=['filename', 'text'],\n keys_idx=[0, 1],\n separator=' ')),\n pipeline=[\n dict(type='LoadImageFromFile'),\n dict(\n type='ResizeOCR',\n height=48,\n min_width=48,\n max_width=160,\n keep_aspect_ratio=True),\n dict(type='ToTensorOCR'),\n dict(type='NormalizeOCR', mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),\n dict(\n type='Collect',\n keys=['img'],\n meta_keys=[\n 'filename', 'ori_shape', 'img_shape', 'text', 'valid_ratio'\n ])\n ],\n test_mode=False)\ntrain_anno_file2 = 'tests/data/ocr_toy_dataset/label.lmdb'\ntrain2 = dict(\n type='OCRDataset',\n img_prefix='tests/data/ocr_toy_dataset/imgs',\n ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n loader=dict(\n type='LmdbLoader',\n repeat=100,\n parser=dict(\n type='LineStrParser',\n keys=['filename', 'text'],\n keys_idx=[0, 1],\n separator=' ')),\n pipeline=[\n dict(type='LoadImageFromFile'),\n dict(\n type='ResizeOCR',\n height=48,\n min_width=48,\n max_width=160,\n
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "TZj5vyqEmulE"
},
"source": [
"### Train the SAR Text Recognizer \n",
"Finally, we train the SAR text recognizer on the toy dataset for five epochs. "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"2021-05-17 18:46:09,650 - mmocr - INFO - Start running, host: SENSETIME\\lintsuihin@hk0014000720l, work_dir: /home/SENSETIME/lintsuihin/code/mmocr-1/demo/tutorial_exps\n",
"2021-05-17 18:46:09,651 - mmocr - INFO - workflow: [('train', 1)], max: 5 epochs\n",
"2021-05-17 18:46:18,432 - mmocr - INFO - Epoch [1][40/125]\tlr: 1.250e-04, eta: 0:02:08, time: 0.219, data_time: 0.054, memory: 2685, loss_ce: 2.8200, loss: 2.8200\n",
"2021-05-17 18:46:25,064 - mmocr - INFO - Epoch [1][80/125]\tlr: 1.250e-04, eta: 0:01:44, time: 0.166, data_time: 0.002, memory: 2685, loss_ce: 1.3645, loss: 1.3645\n",
"2021-05-17 18:46:31,678 - mmocr - INFO - Epoch [1][120/125]\tlr: 1.250e-04, eta: 0:01:32, time: 0.165, data_time: 0.002, memory: 2685, loss_ce: 0.8124, loss: 0.8124\n",
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 8.4 task/s, elapsed: 1s, ETA: 0s2021-05-17 18:46:33,755 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2021-05-17 18:46:33,758 - mmocr - INFO - Saving checkpoint at 1 epochs\n",
"2021-05-17 18:46:35,218 - mmocr - INFO - Epoch(val) [1][125]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2021-05-17 18:46:44,096 - mmocr - INFO - Epoch [2][40/125]\tlr: 1.250e-04, eta: 0:01:26, time: 0.221, data_time: 0.054, memory: 2685, loss_ce: 0.5166, loss: 0.5166\n",
"2021-05-17 18:46:50,754 - mmocr - INFO - Epoch [2][80/125]\tlr: 1.250e-04, eta: 0:01:16, time: 0.166, data_time: 0.002, memory: 2685, loss_ce: 0.3909, loss: 0.3909\n",
"2021-05-17 18:46:57,676 - mmocr - INFO - Epoch [2][120/125]\tlr: 1.250e-04, eta: 0:01:08, time: 0.173, data_time: 0.002, memory: 2685, loss_ce: 0.3378, loss: 0.3378\n",
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 8.2 task/s, elapsed: 1s, ETA: 0s2021-05-17 18:46:59,795 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2021-05-17 18:46:59,796 - mmocr - INFO - Saving checkpoint at 2 epochs\n",
"2021-05-17 18:47:01,088 - mmocr - INFO - Epoch(val) [2][125]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2021-05-17 18:47:09,994 - mmocr - INFO - Epoch [3][40/125]\tlr: 1.250e-04, eta: 0:01:01, time: 0.222, data_time: 0.054, memory: 2685, loss_ce: 0.3060, loss: 0.3060\n",
"2021-05-17 18:47:16,687 - mmocr - INFO - Epoch [3][80/125]\tlr: 1.250e-04, eta: 0:00:53, time: 0.167, data_time: 0.002, memory: 2685, loss_ce: 0.2886, loss: 0.2886\n",
"2021-05-17 18:47:23,357 - mmocr - INFO - Epoch [3][120/125]\tlr: 1.250e-04, eta: 0:00:45, time: 0.167, data_time: 0.002, memory: 2685, loss_ce: 0.2556, loss: 0.2556\n",
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 8.0 task/s, elapsed: 1s, ETA: 0s2021-05-17 18:47:25,454 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2021-05-17 18:47:25,455 - mmocr - INFO - Saving checkpoint at 3 epochs\n",
"2021-05-17 18:47:26,934 - mmocr - INFO - Epoch(val) [3][125]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2021-05-17 18:47:35,666 - mmocr - INFO - Epoch [4][40/125]\tlr: 1.250e-05, eta: 0:00:38, time: 0.217, data_time: 0.054, memory: 2685, loss_ce: 0.2693, loss: 0.2693\n",
"2021-05-17 18:47:42,296 - mmocr - INFO - Epoch [4][80/125]\tlr: 1.250e-05, eta: 0:00:30, time: 0.166, data_time: 0.002, memory: 2685, loss_ce: 0.2633, loss: 0.2633\n",
"2021-05-17 18:47:48,996 - mmocr - INFO - Epoch [4][120/125]\tlr: 1.250e-05, eta: 0:00:23, time: 0.167, data_time: 0.002, memory: 2685, loss_ce: 0.2608, loss: 0.2608\n",
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 8.0 task/s, elapsed: 1s, ETA: 0s2021-05-17 18:47:51,095 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2021-05-17 18:47:51,096 - mmocr - INFO - Saving checkpoint at 4 epochs\n",
"2021-05-17 18:47:52,551 - mmocr - INFO - Epoch(val) [4][125]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2021-05-17 18:48:01,447 - mmocr - INFO - Epoch [5][40/125]\tlr: 1.250e-06, eta: 0:00:15, time: 0.222, data_time: 0.054, memory: 2685, loss_ce: 0.2445, loss: 0.2445\n",
"2021-05-17 18:48:08,136 - mmocr - INFO - Epoch [5][80/125]\tlr: 1.250e-06, eta: 0:00:08, time: 0.167, data_time: 0.002, memory: 2685, loss_ce: 0.2537, loss: 0.2537\n",
"2021-05-17 18:48:14,822 - mmocr - INFO - Epoch [5][120/125]\tlr: 1.250e-06, eta: 0:00:00, time: 0.167, data_time: 0.002, memory: 2685, loss_ce: 0.2528, loss: 0.2528\n",
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 8.0 task/s, elapsed: 1s, ETA: 0s2021-05-17 18:48:16,930 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2021-05-17 18:48:16,931 - mmocr - INFO - Saving checkpoint at 5 epochs\n",
"2021-05-17 18:48:18,350 - mmocr - INFO - Epoch(val) [5][125]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n"
]
}
],
"source": [
"from mmocr.datasets import build_dataset\n",
"from mmocr.models import build_detector\n",
"from mmocr.apis import train_detector\n",
"import os.path as osp\n",
"\n",
"# Build dataset\n",
"datasets = [build_dataset(cfg.data.train)]\n",
"\n",
"# Build the detector\n",
"model = build_detector(\n",
" cfg.model, train_cfg=cfg.get('train_cfg'), test_cfg=cfg.get('test_cfg'))\n",
"# Add an attribute for visualization convenience\n",
"model.CLASSES = datasets[0].CLASSES\n",
"\n",
"# Create work_dir\n",
"mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir))\n",
"train_detector(model, datasets, cfg, distributed=False, validate=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sklydRNXnfJk"
},
"source": [
"### Test and Visualize the Predictions\n",
"\n",
"For completeness, we also perform testing on the latest checkpoint and evaluate the results with hmean-iou metrics. The predictions are saved in the ./outputs file. "
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Use load_from_local loader\n",
"result: {'text': '03/09/2009', 'score': 0.9964864671230316}\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"True"
]
},
"metadata": {},
"execution_count": 11
}
],
"source": [
"from mmocr.apis.inference import model_inference\n",
"from mmdet.apis import init_detector\n",
"\n",
"img = './tests/data/ocr_toy_dataset/imgs/1036169.jpg'\n",
"checkpoint = \"./demo/tutorial_exps/epoch_5.pth\"\n",
"out_file = 'outputs/1036169.jpg'\n",
"\n",
"model = init_detector(cfg, checkpoint, device=\"cuda:0\")\n",
"if model.cfg.data.test['type'] == 'ConcatDataset':\n",
" model.cfg.data.test.pipeline = model.cfg.data.test['datasets'][0].pipeline\n",
"\n",
"\n",
"result = model_inference(model, img)\n",
"print(f'result: {result}')\n",
"\n",
"img = model.show_result(\n",
" img, result, out_file=out_file, show=False)\n",
"\n",
"mmcv.imwrite(img, out_file)"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 192
},
"id": "k3s27QIGQCnT",
"outputId": "4516b2b3-1ca2-4f01-ab8f-9d6b19eb99f1"
},
"source": [
"# Visualize the results\n",
"predicted_img = mmcv.imread('./outputs/1036169.jpg')\n",
"plt.figure(figsize=(4, 4))\n",
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
],
"execution_count": 30,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 288x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"128.489186pt\" version=\"1.1\" viewBox=\"0 0 270.661513 128.489186\" width=\"270.661513pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-17T23:38:30.708885</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 128.489186 \nL 270.661513 128.489186 \nL 270.661513 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 104.611061 \nL 256.4875 104.611061 \nL 256.4875 10.632113 \nL 33.2875 10.632113 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g clip-path=\"url(#pfc91cd2c54)\">\n <image height=\"94\" id=\"imagef8114f6f54\" transform=\"scale(1 -1)translate(0 -94)\" width=\"224\" x=\"33.2875\" xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAOAAAABeCAYAAAA67RjkAACB0ElEQVR4nEz9V5NlV5ali31LbXG0axEeCoGASAApSmRX3a5rt1mkUTzR+CP4xt/Bf0S7tEtai2p2l8isVEiICARCuxZHny2W4sPagWoLA8wjzI/7FmvNNeeYY4wp/u//z/9HDC7gWocUitxopIyE4JBaEAU4F2iswzkIXqK0AhEJeIKLBB8I1uFsQCtJnhvywpBrCTicb3HRE6InBCCARBGlAQFRCpAC7yPWOvIioygKrGtoG4sUCiUU3kWccyitUFKRaYWMEY1ARZBIrLdYZ0FHhJLEKBEhIzjFclXz7NvnvH1zynK6xDcOCQjviL6F6BERYoxEPCJGhFJIYYgxgvAI6YnR4z3EAEpIlNJEPD54YhCARgiBEBBFBEBKBYjusx6iRAqFMRJExNqGGANSCvYPtjk83Gd3Z5fJZIt+b0iW92ido42BICUoBVIQo8C2DhEFRgmEBEEgBgjeEbyF4IgSEAIpJUKAcw3ROyQSKSU600gE0XvauqHeVN09CIpeickyXAwgBUpnIDRNne5XaYUQAUGEANFLJAKtBEIGIoqIgOAIwRFCIASBjxCiRxtFWWTEEKiqhtZ5PGCynCIrca3FW0thDFoqRBTECEIq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