Train for MMOCR from MMLAB KIE models

Task: OCR

Training process for MMOCR from MMLAB in Key Information Extraction (KIE).

🚀 Use with Ikomia API

1. Install Ikomia API

We strongly recommend using a virtual environment. If you're not sure where to start, we offer a tutorial here.

pip install ikomia

2. Create your workflow

To try this code snippet, you can download and extract from wildreceipt. Then make sure you fill the parameter dataset_folder correctly.

from ikomia.dataprocess.workflow import Workflow

# Init your workflow
wf = Workflow()

# Add dataset
dataset = wf.add_task(name="dataset_wildreceipt", auto_connect=False)

# Set dataset parameters
dataset.set_parameters({'dataset_folder': 'dataset/folder'})

# Add algorithm
algo = wf.add_task(name="train_mmlab_kie", auto_connect=True)

# Set parameters
algo.set_parameters({'batch_size': 2})

# Run training

📝 Set algorithm parameters

  • model_name (str, default="sdmgr"): Model name. Set model_name and cfg to choose which model to train. See code snippet below to know what are the possibilities.
  • cfg (str, default=""): Config.
  • pretrain (bool, default=True): Use pretrained model from MMLAB. To train a model from scratch, set this to False.
  • epochs (int, default=10): number of complete passes through the training dataset.
  • batch_size (int, default=4): number of samples processed before the model is updated.
  • dataset_split_ratio (int, default=90): in percentage, divide the dataset into train and evaluation sets ]0, 100[.
  • output_folder (str): path to where the model will be saved. Default folder is "runs/" in the algorithm directory.
  • eval_period (int, default=1): interval between evaluations.
  • dataset_folder (str): path to where the dataset compatible with mmlab is stored. Default folder is "/dataset" in the algorithm directory.
  • expert_mode (bool, default=False): set to True only if you know how mmlab works. Then you can set all the parameters in the mmlab config system and it will override every other parameters above.
  • config_file (str, default=""): path to the .py config file. Only for custom models.
  • model_weight_file (str, default=""): path to the .pth weight file. Only for custom models.

Note: parameter key and value should be in string format when added to the dictionary.

MMLab framework offers multiple models. To ease the choice of couple (model_name/cfg), you can call the function get_model_zoo() to get a list of possible values.

from ikomia.dataprocess.workflow import Workflow

# Init your workflow
wf = Workflow()

# Add kie algorithm
kie = wf.add_task(name="infer_mmlab_kie", auto_connect=True)

# Get list of possible models (model_name, model_config)

☀️ Use with Ikomia Studio

Ikomia Studio offers a friendly UI with the same features as the API.

  • If you haven't started using Ikomia Studio yet, download and install it from this page.

  • For additional guidance on getting started with Ikomia Studio, check out this blog post.


  • Ikomia


Apache License 2.0
Read license full text

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.


Commercial use

License and copyright notice

Trademark use


State changes




Patent use

Private use

This is not legal advice: this description is for informational purposes only and does not constitute the license itself. Provided by