Skip to content

Latest commit

 

History

History
122 lines (102 loc) · 3.92 KB

File metadata and controls

122 lines (102 loc) · 3.92 KB

Mask R-CNN FP32 inference

Description

This document has instructions for running Mask R-CNN FP32 inference using Intel-optimized TensorFlow.

Datasets and Pretrained Model

Download the MS COCO 2014 dataset. Set the DATASET_DIR to point to this directory when running Mask R-CNN.

# Create a new directory, to be set as DATASET_DIR
mkdir $DATASET_DIR
cd $DATASET_DIR

# Download and extract MS COCO 2014 dataset
wget http://images.cocodataset.org/zips/val2014.zip
unzip val2014.zip

wget http://images.cocodataset.org/annotations/annotations_trainval2014.zip
unzip annotations_trainval2014.zip
cp annotations/instances_val2014.json annotations/instances_minival2014.json

export DATASET_DIR=${DATASET_DIR}

Quick Start Scripts

Script name Description
fp32_inference.sh Runs inference with batch size 1 using Coco dataset and pretrained model

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

AI Kit does not currently support TF 1.15.2 models

To run without AI Kit you will need:

  • Python 3.6 or 3.7
  • intel-tensorflow==1.15.2
  • numactl
  • git
  • wget
  • IPython[all]
  • pillow>=8.1.2
  • cython
  • h5py==2.10.0
  • imgaug
  • keras==2.0.8
  • matplotlib
  • numpy==1.16.3
  • opencv-python
  • pycocotools
  • scikit-image
  • scipy==1.2.0
  • A clone of the Model Zoo repo
    git clone https://github.com/IntelAI/models.git

Running Mask R-CNN also requires a clone and particular SHA of the Mask R-CNN model repository. Set the MODEL_SRC_DIR env var to the path of your clone.

git clone https://github.com/matterport/Mask_RCNN.git
cd Mask_RCNN
git checkout 3deaec5d902d16e1daf56b62d5971d428dc920bc
export MODEL_SRC_DIR=$(pwd)

Download pre-trained COCO weights mask_rcnn_coco.h5) from the Mask R-CNN repository release page, and place it in the MaskRCNN directory.

wget -q https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5
cd ..

After your environment is setup, set environment variables to the DATASET_DIR and an OUTPUT_DIR where log files will be written. Ensure that you already have the MODEL_SRC_DIR path set from the previous commands. Once the environment variables are all set, you can run the quickstart script.

# cd to your model zoo directory
cd models

export DATASET_DIR=<path to the dataset>
export OUTPUT_DIR=<directory where log files will be written>
export MODEL_SRC_DIR=<path to the Mask RCNN models repo with pre-trained model>

./quickstart/image_segmentation/tensorflow/maskrcnn/inference/cpu/fp32/fp32_inference.sh

Additional Resources