PaddleOCR

How to integrate W&B with PaddleOCR.

PaddleOCR aims to create multilingual, awesome, leading, and practical OCR tools that help users train better models and apply them into practice implemented in PaddlePaddle. PaddleOCR support a variety of cutting-edge algorithms related to OCR, and developed industrial solution. PaddleOCR now comes with a Weights & Biases integration for logging training and evaluation metrics along with model checkpoints with corresponding metadata.

Example Blog & Colab

Read here to see how to train a model with PaddleOCR on the ICDAR2015 dataset. This also comes with a Google Colab and the corresponding live W&B dashboard is available here. There is also a Chinese version of this blog here: W&B对您的OCR模型进行训练和调试

Sign up and create an API key

An API key authenticates your machine to W&B. You can generate an API key from your user profile.

  1. Click your user profile icon in the upper right corner.
  2. Select User Settings, then scroll to the API Keys section.
  3. Click Reveal. Copy the displayed API key. To hide the API key, reload the page.

Install the wandb library and log in

To install the wandb library locally and log in:

  1. Set the WANDB_API_KEY environment variable to your API key.

    export WANDB_API_KEY=<your_api_key>
    
  2. Install the wandb library and log in.

    pip install wandb
    
    wandb login
    
pip install wandb
import wandb
wandb.login()
!pip install wandb

import wandb
wandb.login()

Add wandb to your config.yml file

PaddleOCR requires configuration variables to be provided using a yaml file. Adding the following snippet at the end of the configuration yaml file will automatically log all training and validation metrics to a W&B dashboard along with model checkpoints:

Global:
    use_wandb: True

Any additional, optional arguments that you might like to pass to wandb.init can also be added under the wandb header in the yaml file:

wandb:  
    project: CoolOCR  # (optional) this is the wandb project name 
    entity: my_team   # (optional) if you're using a wandb team, you can pass the team name here
    name: MyOCRModel  # (optional) this is the name of the wandb run

Pass the config.yml file to train.py

The yaml file is then provided as an argument to the training script available in the PaddleOCR repository.

python tools/train.py -c config.yml

Once you run your train.py file with Weights & Biases turned on, a link will be generated to bring you to your W&B dashboard:

W&B Dashboard for the Text Detection Model

Feedback or issues

If you have any feedback or issues about the Weights & Biases integration please open an issue on the PaddleOCR GitHub or email support@wandb.com.


Last modified February 20, 2025: c1984ba