NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
EfficientDet For TensorFlow2
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
EfficientDet For TensorFlow2

A convolution-based neural network for the task of object detection.

To train your model using mixed or TF32 precision with Tensor Cores or using FP32, perform the following steps using the default parameters of the EfficientDet on the COCO 2017 dataset. For the specifics concerning training and inference, refer to the Advanced section.

1. Clone the repository

git clone https://github.com/NVIDIA/DeepLearningExamples.git
cd DeepLearningExamples/Tensorflow2/Detection/EfficientDet

2. Download and preprocess the dataset

To download COCO 2017 images and annotations and convert them to tfrecords, run the script as follows:

bash dataset/get_coco.sh

By default, the data is organized into the following structure:

</workspace/coco/>
  train-*****-of-00256.tfrecord
  val-*****-of-00032.tfrecord

3. Build the EfficientDet PyTorch NGC container

bash scripts/docker/build.sh

4. Start an interactive session in the NGC container to run training/inference

After you build the container image, you can start an interactive CLI session with

DATA=<path to coco tfrecords> BACKBONE_CKPT=<path to pretrained efficientnet checkpoint> bash scripts/docker/interactive.sh

Note: The interactive.sh script requires the location of the dataset and the pretrained checkpoint to be passed.

5. Start training

bash ./scripts/D0/convergence-{AMP, FP32, TF32}-{8, 32}x{V100-32G, A100-80G}.sh

The training scripts train EfficientDet-D0 and perform an evaluation on the COCO 2017 dataset. By default, the training script runs training on standard configuration (DGX A100/DGX-1 V100, AMP/FP32/TF32, 300 epochs). Run one of the scripts in scripts/D0 directory using bash scripts/D0/convergence-{AMP, FP32, TF32}-{8, 32}x{V100-32G, A100-80G}.sh. Ensure COCO-2017 tfrecords are mounted to /workspace/coco and EfficientNet-B0 backbone weights are mounted to /workspace/checkpoints. The backbone checkpoint can be downloaded from this location.

After training, the logs are present in the model directory where the data is organized in the following structure:

</tmp/convergence-{AMP, FP32, TF32}-{8, 32}x{V100-32G, A100-80G}>
  ema_weights                           *contains the ema checkpoints of the model, checkpointed after every 10 epochs of training*
    checkpoint
    emackpt-10.data-00000-of-00001
    emackpt-10.index
    emackpt-20.data-00000-of-00001
    emackpt-20.index
    ...
    emackpt-300.data-00000-of-00001
    emackpt-300.index
  emackpt-final                         *final savedmodel with ema weights which can be used for inference*
    assets
    variables
      variables.data-00000-of-00001
      variables.index
    keras_metadata.pb
    saved_model.pb
  train *tensorboard logs*
    events.out.tfevents.*
  checkpoint
  ckpt.data-00000-of-00001
  ckpt.index
  ckpt-final.data-00000-of-00001
  ckpt-final.index
  time_log.txt                          *dllogger logs*
  train-<time_stamp>.log                *training log file*

6. Start validation/evaluation

To run validation/evaluation for a standard configuration (DGX A100/DGX-1 V100, AMP/TF32/FP32, EfficientDet-D0), run one of the evaluation scripts in scripts/D0 directory using bash scripts/D0/evaluate-{AMP, FP32, TF32}-{8, 32}x{A100-80G, V100-32G}.sh. The script requires:

  • CKPT is the path to the checkpoint that needs to be evaluated. For example, CKPT=/tmp/convergence-AMP-8xA100-80G/ema_weights/emackpt-300

Evaluation command:

CKPT=<path to checkpoint> bash ./scripts/D0/evaluate-{AMP, FP32, TF32}-{8, 32}x{A100-80G, V100-32G}.sh

Ensure COCO-2017 is mounted in /workspace/coco.

7. Inference benchmark

Inference loop can be benchmarked by running the scripts/D0/inference-benchmark.sh script. The script requires:

  • batch size to use for inference BS. For example, BS=128
  • Boolean to enable/disable AMP (Automatic Mixed Precision)

Inference benchmark command:

BS=<batch size> AMP=<True/False for Automatic Mixed Precision> bash scripts/D0/inference-benchmark.sh

8. Inference/Prediction

Model predictions can be obtained by running the scripts/D0/inference.sh script. This script reads a test image and annotates the image after object detection by drawing boxes on the objects in the image. The script requires:

  • MODEL_DIR in which the file checkpoint contains path to the latest checkpoint that needs to be used for inference. For example, MODEL_DIR=/tmp/convergence-AMP-8xA100-80G/ema_weights

Inference command:

MODEL_DIR=<path to trained model directory> bash scripts/D0/inference.sh

Note that the above script assumes that the test image is present in testdata and is named img1.jpg.

NVIDIA uses cookies to improve your experience on our web site. We and our third-party partners also use cookies and other tools to collect and record information you provide as well as information about your interactions with our websites for performance improvement, analytics, and to assist in marketing efforts. By clicking "Accept All", you consent to our use of cookies and other tools as described in our Cookie Policy. You can manage your cookie settings by clicking on "Manage Settings." By continuing to use this site or by clicking one of the buttons below, you agree to our Terms of Service (which contains important waivers). Please see our Privacy Policy for more information on our privacy practices.