Skip to content

Commit

Permalink
Merge pull request ARM-software#1 from ARM-software/ssd_mobilenet
Browse files Browse the repository at this point in the history
Added SSD MobileNet v1 FP32 & UINT8
  • Loading branch information
tom-arm authored Dec 3, 2020
2 parents ee35139 + 7ffc4fc commit ff25f80
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_STORE
6 changes: 6 additions & 0 deletions MODEL_LIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
| [DS-CNN Large INT8](models/keyword_spotting/ds_cnn_large/tflite_int8) | INT8 | TensorFlow Lite |
| [DS-CNN Medium INT8](models/keyword_spotting/ds_cnn_medium/tflite_int8) | INT8 | TensorFlow Lite |
| [DS-CNN Small INT8](models/keyword_spotting/ds_cnn_small/tflite_int8) | INT8 | TensorFlow Lite |

## Object Detection
| Model Name | Datatype | Framework |
|-----------------|---------|--------------|
| [SSD MobileNet v1 FP32](models/object_detection/ssd_mobilenet_v1/tflite_fp32) | FP32 | TensorFlow Lite |
| [SSD MobileNet v1 UINT8](models/object_detection/ssd_mobilenet_v1/tflite_uint8) | UINT8 | TensorFlow Lite |
36 changes: 36 additions & 0 deletions models/object_detection/ssd_mobilenet_v1/tflite_fp32/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SSD MobileNet v1 FP32

## Description
SSD MobileNet v1 is a object detection network, that localizes and identifies objects in an input image. This is a TF Lite floating point version that takes a 300x300 input image and outputs detections for this image. This model is trained by Google.

## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Network Information
| Network Information | Value |
|---------------------|------------------|
| Framework | TensorFlow Lite |
| SHA-1 Hash | 5bd511fc17ec7bfe9cd0f51bdec1537b874f52d2 |
| Size (Bytes) | 27286108 |
| Provenance | http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz |
| Paper | https://arxiv.org/abs/1512.02325 |

## Accuracy
Dataset: Coco Validation 2017

| Metric | Value |
|--------|-------|
| mAP | 0.21 |

## Network Inputs
| Input Node Name | Shape | Description |
|-----------------|---------|-------------|
| normalized_input_image_tensor | (1, 300, 300, 3) | A float input image. |

## Network Outputs
| Output Node Name | Shape | Description |
|------------------|---------|-------------|
| TFLite_Detection_PostProcess | () | An array of num_detection box boundaries for each input in the format (y1, x1, y2, x2) scaled from 0 to 1. |
| TFLite_Detection_PostProcess:1 | () | COCO detection classes for each object. 1=person, 11=fire hydrant. |
| TFLite_Detection_PostProcess:2 | () | Detection scores for each object. |
| TFLite_Detection_PostProcess:3 | () | The number of objects detected in each image. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SSD MobileNet v1 FP32 Model Re-Creation
This folder contains a script that allows for the model to be re-created from scratch.

## Requirements
The script in this folder requires that the following must be installed:
- Python 3.7
- protoc

## Running The Script
To run the script, run the following in a terminal: `./recreate_model.sh`
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

python3.7 -m venv venv
source venv/bin/activate

pip install -r requirements.txt

git clone https://github.com/tensorflow/models.git
pushd models/research

export PYTHONPATH=`pwd`:`pwd`/slim:$PYTHONPATH
protoc object_detection/protos/*.proto --python_out=.

wget http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz
tar -xvf ssd_mobilenet_v1_coco_2018_01_28.tar.gz

python object_detection/export_tflite_ssd_graph.py --pipeline_config_path=object_detection/samples/configs/ssd_mobilenet_v1_coco.config --trained_checkpoint_prefix=ssd_mobilenet_v1_coco_2018_01_28/model.ckpt --output_directory=. --add_postprocessing_op=true
tflite_convert --graph_def_file=tflite_graph.pb --output_file=ssd_mobilenet_v1.tflite --input_shapes=1,300,300,3 --input_arrays=normalized_input_image_tensor --output_arrays=TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3 --change_concat_input_ranges=false --allow_custom_ops

mv ssd_mobilenet_v1.tflite ../..

popd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
absl-py==0.11.0
astor==0.8.1
cached-property==1.5.2
certifi==2020.6.20
cycler==0.10.0
gast==0.2.2
google-pasta==0.2.0
grpcio==1.33.2
h5py==3.0.0
importlib-metadata==2.0.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
kiwisolver==1.3.1
Markdown==3.3.3
matplotlib==3.3.2
mock==4.0.2
numpy==1.18.5
opt-einsum==3.3.0
Pillow==8.0.1
protobuf==3.13.0
pyparsing==2.4.7
python-dateutil==2.8.1
scipy==1.5.4
six==1.15.0
tensorboard==1.15.0
tensorflow==1.15.4
tensorflow-estimator==1.15.1
termcolor==1.1.0
tf-slim==1.1.0
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.4.0
Git LFS file not shown
41 changes: 41 additions & 0 deletions models/object_detection/ssd_mobilenet_v1/tflite_uint8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SSD MobileNet v1 UINT8

## Description
SSD MobileNet v1 is a object detection network, that localizes and identifies objects in an input image. This is a TF Lite quantized version that takes a 300x300 input image and outputs detections for this image. This model is trained and quantized by Google.

## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Network Information
| Network Information | Value |
|---------------------|------------------|
| Framework | TensorFlow Lite |
| SHA-1 Hash | 1f9c945db9e32c33e5b91539f756a8fbef636405 |
| Size (Bytes) | 6898880 |
| Provenance | http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18.tar.gz |
| Paper | https://arxiv.org/abs/1512.02325 |

## Accuracy
Dataset: Coco Validation 2017

| Metric | Value |
|--------|-------|
| mAP | 0.18 |

## Optimizations
| Optimization | Value |
|-----------------|---------|
| Quantization | UINT8 |

## Network Inputs
| Input Node Name | Shape | Description |
|-----------------|---------|-------------|
| image_tensor | (1, 300, 300, 3) | Input RGB images (a range of 0-255 per RGB channel). |

## Network Outputs
| Output Node Name | Shape | Description |
|------------------|---------|-------------|
| TFLite_Detection_PostProcess | () | The y1, x1, y2, x2 coordinates of the bounding boxes for each detection |
| TFLite_Detection_PostProcess:1 | () | The class of each detection |
| TFLite_Detection_PostProcess:2 | () | The probability score for each classification |
| TFLite_Detection_PostProcess:3 | () | A vector containing a number corresponding to the number of detections |
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SSD MobileNet v1 UINT8 Model Re-Creation
This folder contains a script that allows for the model to be re-created from scratch.

## Requirements
The script in this folder requires that the following must be installed:
- Python 3.7

## Running The Script
To run the script, run the following in a terminal: `./recreate_model.sh`
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

python3.7 -m venv venv
source venv/bin/activate

pip install -r requirements.txt

wget http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18.tar.gz
tar -xvf ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18.tar.gz

pushd ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18

tflite_convert --graph_def_file=tflite_graph.pb --output_file=ssd_mobilenet_v1.tflite --input_shapes=1,300,300,3 --input_arrays=normalized_input_image_tensor --output_arrays=TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3 --change_concat_input_ranges=false --allow_custom_ops --inference_type=QUANTIZED_UINT8 --mean_values=128 --std_dev_values=128
mv ssd_mobilenet_v1.tflite ..

popd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
absl-py==0.11.0
astor==0.8.1
cached-property==1.5.2
gast==0.2.2
google-pasta==0.2.0
grpcio==1.33.2
h5py==3.0.0
importlib-metadata==2.0.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
Markdown==3.3.3
numpy==1.18.5
opt-einsum==3.3.0
protobuf==3.13.0
six==1.15.0
tensorboard==1.15.0
tensorflow==1.15.4
tensorflow-estimator==1.15.1
termcolor==1.1.0
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.4.0
Git LFS file not shown

0 comments on commit ff25f80

Please sign in to comment.