The Optical Character Recognition (OCR) template is used to extract text from an input image and then classifies images based on the text. You can complete labeling jobs by using the predefined OCR template that is provided by smart labeling of Machine Learning Platform for AI.

Prerequisites

Download the demo data, and import the data. For more information, see Register a dataset.

Background information

For more information about the data schema of the OCR template, see Data labeling templates.

Step 1: Create a labeling job

  1. Log on to the Machine Learning Platform for AI console.
  2. In the left-side navigation pane of the Machine Learning Platform for AI console, select Data Preprocessing > Smart Labeling.
  3. On the Smart Labeling page, click Create Labeling Job.
  4. Configure the basic information and then click Next.
    Parameter Description
    Task Name Enter ocr_tag.
    Description Enter OCR-based data labeling demo.
    Input Dataset Select the registered dataset at the time of data import.
    Output Dataset Path Select an Object Storage Service (OSS) path, for example, oss://****.oss-cn-shanghai.aliyuncs.com/testData/.
  5. Configure the template, and then click Next.
    Parameter Description
    Template Select OCR template.
    Image and Text Orientation Turn on the Label Image Orientation and Flip Text switches.
    Text Type Add the Name, Tel, Address, Company, and Others labels.
    Add Custom Label Enter Region into the Label Name field and enter North and South into the Label Value field.
  6. Configure the labeling policy, and then click Submit.
    Parameter Description
    Dispatch Policy The default dispatch policy is Number of topics collected by a worker each time and cannot be changed.
    Topics per Collection Enter 100.
    Add Worker Select Select All.

Step 2: Label images

  1. Navigate to the Smart Labeling page.
    1. In the left-side navigation pane of the Machine Learning Platform for AI console, select Data Preprocessing > Smart Labeling.
    2. On the Smart Labeling page, click My Labeling Jobs.
    3. Find the target labeling job in the job list, and click Start in the Actions column.
  2. Label images.
    1. On the Smart Labeling page, click the Rectangle selection tool icon icon to use the rectangle selection tool.
    2. Label images.OCR-based labeling
      Select the target text in the image, and click Smart Recognition to recognize the text. If the image is flipped, you must modify the orientation of the entire image. If the text is flipped, you must adjust the text direction.
    3. Click Submit.
    4. You can browse and complete topics in the following ways:
      • Click Prev or Next at the bottom of the Smart Labeling page.
      • Click the thumbnails of the topics in the left-side pane.

Step 3: View the labeling result

  1. Generate a result dataset.
    1. In the left-side navigation pane of the Machine Learning Platform for AI console, select Data Preprocessing > Smart Labeling.
    2. On the Smart Labeling page, click My Jobs.
    3. Find the target labeling job in the job list, and click Generate Result Dataset in the Actions column.
    4. In the Do you want to generate a result dataset? message, click OK.
  2. In the OSS path that you have specified on the Output Dataset Path tab, view the labeling result (a manifest file).
    Each row in the manifest file contains a topic and the corresponding labeling result. The following is an example of the JSON string in each row:
    {
        "data": {
            "picUrl":"oss://****/img/ocr_card/img0.jpeg"
        },
        "label-****(Labeling job ID)": {
            "results":[{
                "data": [{
                    "direction_of_picture":"downward",
                    "type":"ocr/meta"
                },
                {
                    "id":"Y4ZFoC-****",
                    "direction_of_text":"downward",
                    "text":"Room 403, Floor 4, Building 2, International Pioneer Park, Shangdi No.7 Street, Haidian District, Beijing",
                    "type":"ocr/polygonLabel",
                    "value":{
                        "points":[[325.08789110183716,397.47582054138184], ...]
                    },
                    "labelColor":"#67bd3a",
                    "labels":"Address"
                }],
                "id":"24****",
                "type":"ocr"
            }]
        }
    }