This document has instructions for running ResNet101 inference using Intel-optimized TensorFlow.
Download and preprocess the ImageNet dataset using the instructions here. After running the conversion script you should have a directory with the ImageNet dataset in the TF records format.
Set the DATASET_DIR
to point to this directory when running ResNet101.
Script name | Description |
---|---|
online_inference.sh |
Runs online inference (batch_size=1). |
batch_inference.sh |
Runs batch inference (batch_size=128). |
accuracy.sh |
Measures the model accuracy (batch_size=100). |
Setup your environment using the instructions below, depending on if you are using AI Kit:
Setup using AI Kit on Linux | Setup without AI Kit on Linux | Setup without AI Kit on Windows |
---|---|---|
To run using AI Kit on Linux you will need:
|
To run without AI Kit on Linux you will need:
|
To run without AI Kit on Windows you will need:
|
After finishing the setup above, download the pretrained model based on PRECISION
and set the
PRETRAINED_MODEL
environment var to the path to the frozen graph.
If you run on Windows, please use a browser to download the pretrained model using the link below.
For Linux, run:
# FP32 Pretrained model:
wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/resnet101_fp32_pretrained_model.pb
export PRETRAINED_MODEL=$(pwd)/resnet101_fp32_pretrained_model.pb
# Int8 Pretrained model:
wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/resnet101_int8_pretrained_model.pb
export PRETRAINED_MODEL=$(pwd)/resnet101_int8_pretrained_model.pb
Intel® Neural Compressor int8 quantized ResNet101 pre-trained model is available as another option to download and try.
wget https://storage.googleapis.com/intel-optimized-tensorflow/intel-neural-compressor/v1_13/resnet-101-inc-int8-inference.pb
export PRETRAINED_MODEL=$(pwd)/resnet-101-inc-int8-inference.pb
Check the instructions for more details on how to quantize FP32 model using Intel® Neural Compressor.
Set the environment variables and run quickstart script on either Linux or Windows systems. See the list of quickstart scripts for details on the different options.
# cd to your model zoo directory
cd models
export PRETRAINED_MODEL=<path to the frozen graph downloaded above>
export DATASET_DIR=<path to the ImageNet TF records>
export PRECISION=<set the precision to "int8" or "fp32">
export OUTPUT_DIR=<path to the directory where log files will be written>
# For a custom batch size, set env var `BATCH_SIZE` or it will run with a default value.
export BATCH_SIZE=<customized batch size value>
./quickstart/image_recognition/tensorflow/resnet101/inference/cpu/<script name>.sh
Using cmd.exe
, run:
# cd to your model zoo directory
cd models
set PRETRAINED_MODEL=<path to the frozen graph downloaded above>
set DATASET_DIR=<path to the ImageNet TF records>
set PRECISION=<set the precision to "int8" or "fp32">
set OUTPUT_DIR=<directory where log files will be written>
# For a custom batch size, set env var `BATCH_SIZE` or it will run with a default value.
set BATCH_SIZE=<customized batch size value>
bash quickstart\image_recognition\tensorflow\resnet101\inference\cpu\<script name>.sh
Note: You may use
cygpath
to convert the Windows paths to Unix paths before setting the environment variables. As an example, if the dataset location on Windows isD:\user\ImageNet
, convert the Windows path to Unix as shown:cygpath D:\user\ImageNet /d/user/ImageNet
Then, set the
DATASET_DIR
environment variableset DATASET_DIR=/d/user/ImageNet
.
- To run more advanced use cases, see the instructions for the available precisions FP32 Int8 for calling the
launch_benchmark.py
script directly. - To run the model using docker, please see the Intel® Developer Catalog
workload container:
https://software.intel.com/content/www/us/en/develop/articles/containers/resnet101-fp32-inference-tensorflow-container.html.