Skip to content

Latest commit

 

History

History
159 lines (139 loc) · 6.39 KB

File metadata and controls

159 lines (139 loc) · 6.39 KB

SSD-ResNet34 BFloat16 inference

Description

This document has instructions for running SSD-ResNet34 BFloat16 inference using Intel-optimized TensorFlow.

Datasets

The SSD-ResNet34 accuracy scripts (bfloat16_accuracy.sh and bfloat16_accuracy_1200.sh) use the COCO validation dataset in the TF records format. See the COCO dataset document for instructions on downloading and preprocessing the COCO validation dataset.

The performance benchmarking scripts (bfloat16_inference.sh and bfloat16_inference_1200.sh) use synthetic data, so no dataset is required.

Quick Start Scripts

Script name Description
bfloat16_accuracy_1200.sh Runs an accuracy test using data in the TF records format with an input size of 1200x1200.
bfloat16_accuracy.sh Runs an accuracy test using data in the TF records format with an input size of 300x300.
bfloat16_inference_1200.sh Runs inference with a batch size of 1 using synthetic data with an input size of 1200x1200. Prints out the time spent per batch and total samples/second.
bfloat16_inference.sh Runs inference with a batch size of 1 using synthetic data with an input size of 300x300. Prints out the time spent per batch and total samples/second.

Run the model

Setup your environment using the instructions below, depending on if you are using AI Kit:

Setup using AI Kit Setup without AI Kit

To run using AI Kit you will need:

  • build-essential
  • git
  • libgl1-mesa-glx
  • libglib2.0-0
  • numactl
  • python3-dev
  • wget
  • Cython
  • contextlib2
  • horovod==0.19.1
  • jupyter
  • lxml
  • matplotlib
  • numpy>=1.17.4
  • opencv-python
  • pillow>=8.1.2
  • pycocotools
  • tensorflow-addons==0.11.0
  • Activate the tensorflow 2.5.0 conda environment
    conda activate tensorflow

To run without AI Kit you will need:

  • Python 3
  • build-essential
  • git
  • libgl1-mesa-glx
  • libglib2.0-0
  • numactl
  • python3-dev
  • wget
  • intel-tensorflow>=2.5.0
  • Cython
  • contextlib2
  • horovod==0.19.1
  • jupyter
  • lxml
  • matplotlib
  • numpy>=1.17.4
  • opencv-python
  • pillow>=8.1.2
  • pycocotools
  • tensorflow-addons==0.11.0
  • A clone of the Model Zoo repo
    git clone https://github.com/IntelAI/models.git

The TensorFlow models and benchmarks repos are used by SSD-ResNet34 BFloat16 inference. Clone those at the git SHAs specified below and set the TF_MODELS_DIR environment variable to point to the directory where the models repo was cloned.

git clone --single-branch https://github.com/tensorflow/models.git tf_models
git clone --single-branch https://github.com/tensorflow/benchmarks.git ssd-resnet-benchmarks
cd tf_models
export TF_MODELS_DIR=$(pwd)
git checkout f505cecde2d8ebf6fe15f40fb8bc350b2b1ed5dc
cd ../ssd-resnet-benchmarks
git checkout 509b9d288937216ca7069f31cfb22aaa7db6a4a7
cd ..

Download the SSD-ResNet34 pretrained model for either the 300x300 or 1200x1200 input size, depending on which quickstart script you are going to run. Set the PRETRAINED_MODEL environment variable for the path to the pretrained model that you'll be using.

# ssd-resnet34 300x300
wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/ssd_resnet34_fp32_bs1_pretrained_model.pb
export PRETRAINED_MODEL=$(pwd)/ssd_resnet34_fp32_bs1_pretrained_model.pb

# ssd-resnet34 1200x1200
wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/ssd_resnet34_fp32_1200x1200_pretrained_model.pb
export PRETRAINED_MODEL=$(pwd)/ssd_resnet34_fp32_1200x1200_pretrained_model.pb

After installing the prerequisites and cloning the models and benchmarks repos, and downloading the pretrained model, set environment variables for the path to your DATASET_DIR (for accuracy testing only -- inference benchmarking uses synthetic data) and an OUTPUT_DIR where log files will be written. Once the required environment variables are set, you can then run a quickstart script from the Model Zoo.

# cd to your model zoo directory
cd models

# set environment variables
export DATASET_DIR=<directory with the validation-*-of-* files (for accuracy testing only)>
export TF_MODELS_DIR=<path to the TensorFlow Models repo>
export PRETRAINED_MODEL=<path to the 300x300 or 1200x1200 pretrained model pb file>
export OUTPUT_DIR=<directory where log files will be written>

./quickstart/object_detection/tensorflow/ssd-resnet34/inference/cpu/bfloat16/<script name>.sh

Additional Resources