PaddleDetection And W&B Your One Stop For Everything Object Detection
Train and Debug your Object Detection Models with PaddleDetection and W&B 🪄🐝
PaddleDetection is an end-to-end object detection development kit based on PaddlePaddle, which implements varied mainstream object detection, instance segmentation, tracking and keypoint detection algorithms in modular design with configurable modules such as network components, data augmentations and losses.
This notebook will walk you through how to use the W&B integration in PaddleDetection to track your model training and save model checkpoints.
The W&B integration in PaddleDetection can be used in two ways
- Command Line
python tools/train -c config.yml --use_wandb -o wandb-project=MyDetector wandb-entity=MyTeam wandb-save_dir=./logs
The arguments to the W&B logger must be proceeded by -o and each invidiual argument must contain the prefix "wandb-" and the --use_wandb flag should be used.
- YAML File: Add the arguments to the config.yml file under the wandb header like this
wandb:
project: MyProject
entity: MyTeam
save_dir: ./logs
Setup 🖥
We begin by installing the PaddlePaddle library followed by PaddleDetection
Now we'll install and log into W&B.
A few more imports and we are good to go!
Dataset 💿
We begin by downloading a subset of the COCO 2017 dataset created using this amazing repository
The dataset has been logged as a W&B artifact for easier downloading. It contains 1000 images for training and 250 for validation with corresponding annotations which we will now use for training our object detection model.
Training 🏋️♀️
Setting up the configuration 🛠
The configuration for the model is provided to the training script through yaml files in PaddleDetection so we're going to go ahead and edit it to suit our needs.
Training the Model 🏋️♀️
We now use the training script in the PaddleDetection library to train the YOLOX model and the config above adds W&B logging during training. We also add the --eval flag to have an evaluation step every 5 epochs since the validation set is extremely large.
Visualization
During training the metrics on the training and validation sets are logged to a W&B dashboard which looks something like this
The model checkpoints are also logged at the end of every snapshot epoch along with the corresponding average precision.
Evaluation and Testing 🤔
Download the Best Model from W&B 💾
To download the model with the best accuracy from W&B for evaluation you can use the following snippet
Testing and Logging annotated images to your W&B dashboard 🔥
The following cell runs the inference script on all the images in demo directory and stores the annotated images with the bounding boxes in the infer_output directory using the YOLOX model pulled from W&B.
With the images being annotated, we will now initialize a new run in the project and a W&B table which we will then use to add the input and output images side-by-side.
The next cell iterates over the images and adds the corresponding inputs and outputs as a row in the table initialized in the previous cell.
This provides a really cool debugging tool!
Resources📕
- W&B and PaddleDetection Documentation contains a few tips for taking most advantage of W&B.
- More PaddleDetection documentation is available here
Questions about W&B❓
If you have any questions about using W&B to track your model performance and predictions, please contact support@wandb.com