Run ResNet-34* SSD FP32 Training with a TensorFlow* Container

ID 679166
Updated 6/15/2022
Version Latest
Public

author-image

By

Pull Command

docker pull intel/object-detection:tf-latest-ssd-resnet34-fp32-training

Description

This document has instructions for running ResNet34 SSD FP32 training using Intel® Optimization for TensorFlow*.

Datasets

ResNet34 SSD training uses the COCO dataset. Use the following instructions to download and preprocess the dataset.

  1. Download and extract the 2017 training images and annotations for the COCO dataset:

    export MODEL_WORK_DIR=$(pwd)
    
    # Download and extract train images
    wget http://images.cocodataset.org/zips/train2017.zip
    unzip train2017.zip
    
    # Download and extract annotations
    wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip
    unzip annotations_trainval2017.zip
  2. Since we are only using the train and validation dataset in this example, we will create an empty directory and empty annotations JSON file to pass as the test directories in the next step.

    # Create an empty dir to pass for validation and test images
    mkdir empty_dir
    
    # Add an empty .json file to bypass validation/test image preprocessing
    cd annotations
    echo "{ \"images\": {}, \"categories\": {}}" > empty.json
    cd ..
  3. Use the TensorFlow models repo scripts to convert the raw images and annotations to the TF records format.

    git clone https://github.com/tensorflow/models.git tf_models
    cd tf_models
    git checkout 7a9934df2afdf95be9405b4e9f1f2480d748dc40
    cd ..
  4. Install the prerequisites mentioned in the TensorFlow models object detection installation doc and run protobuf compilation on the code that was cloned in the previous step.

  5. After your envionment is setup, run the conversion script:

    cd tf_models/research/object_detection/dataset_tools/
    
    # call script to do conversion
    python create_coco_tf_record.py --logtostderr \
          --train_image_dir="$MODEL_WORK_DIR/train2017" \
          --val_image_dir="$MODEL_WORK_DIR/empty_dir" \
          --test_image_dir="$MODEL_WORK_DIR/empty_dir" \
          --train_annotations_file="$MODEL_WORK_DIR/annotations/instances_train2017.json" \
          --val_annotations_file="$MODEL_WORK_DIR/annotations/empty.json" \
          --testdev_annotations_file="$MODEL_WORK_DIR/annotations/empty.json" \
          --output_dir="$MODEL_WORK_DIR/output"

    The coco_train.record-*-of-* files are what we will use in this training example. Set the output of the preprocessing script (export DATASET_DIR=$MODEL_WORK_DIR/output) when running quick start scripts.

Quick Start Scripts

Script name Description
fp32_training Runs 100 training steps using mpirun for the specified number of processes (defaults to MPI_NUM_PROCESSES=1).

Docker*

The model container includes the scripts and libraries needed to run ResNet34 SSD FP32 training. To run one of the quick start scripts using this container, you'll need to provide volume mounts for the dataset and an output directory where the log file will be written. To run more than one process, set the MPI_NUM_PROCESSES environment variable in the container.

DATASET_DIR=<path to the dataset>
OUTPUT_DIR=<directory where log and checkpoint files will be written>
MPI_NUM_PROCESSES=<number of MPI processes (optional, defaults to 1)>

docker run \
  --env DATASET_DIR=${DATASET_DIR} \
  --env OUTPUT_DIR=${OUTPUT_DIR} \
  --env MPI_NUM_PROCESSES=${MPI_NUM_PROCESSES} \
  --env http_proxy=${http_proxy} \
  --env https_proxy=${https_proxy} \
  --volume ${DATASET_DIR}:${DATASET_DIR} \
  --volume ${OUTPUT_DIR}:${OUTPUT_DIR} \
  --privileged --init -it \
  intel/object-detection:tf-latest-ssd-resnet34-fp32-training \
  /bin/bash quickstart/<script name>.sh

Documentation and Sources

Get Started​
Docker* Repository
Main GitHub*
Readme
Release Notes
Get Started Guide

Code Sources
Dockerfile
Report Issue


License Agreement

LEGAL NOTICE: By accessing, downloading or using this software and any required dependent software (the “Software Package”), you agree to the terms and conditions of the software license agreements for the Software Package, which may also include notices, disclaimers, or license terms for third party software included with the Software Package. Please refer to the license file for additional details.


View All Containers and Solutions 🡢