Skip to content

Commit

Permalink
add efficientdets
Browse files Browse the repository at this point in the history
  • Loading branch information
jkamelin committed Nov 5, 2020
1 parent 0476ba9 commit 5944695
Show file tree
Hide file tree
Showing 13 changed files with 738 additions and 0 deletions.
23 changes: 23 additions & 0 deletions models/public/efficientdet-d0-tf/accuracy-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
models:
- name: efficientdet-d0-tf
launchers:
- framework: dlsdk
adapter: ssd
datasets:
- name: ms_coco_detection_90_class_without_backgound
preprocessing:
- type: resize
aspect_ratio_scale: fit_to_window
size: 512
- type: padding
size: 512
pad_type: right_bottom

postprocessing:
- type: faster_rcnn_postprocessing_resize
size: 512
- type: shift_labels
offset: 1

metrics:
- type: coco_precision
86 changes: 86 additions & 0 deletions models/public/efficientdet-d0-tf/efficientdet-d0-tf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# efficientdet-d0-tf

## Use Case and High-Level Description

The "efficientdet-d0" model is one of the [EfficientDet](https://arxiv.org/abs/1911.09070)
models designed to perform object detection. This model was pretrained in TensorFlow*.
All the EfficientDet models have been pretrained on the MSCOCO* image database.
For details about this family of models, check out the Google AutoML [repository]
(https://github.com/google/automl/tree/master/efficientdet).

## Example

## Specification

| Metric | Value |
|-------------------|-----------------|
| Type | Object detection|
| GFLOPs | 0.819 |
| MParams | 5.268 |
| Source framework | TensorFlow\* |

## Accuracy

| Metric | Converted model |
| ------ | --------------- |
| coco_precision | 31.95%|

## Performance

## Input

### Original Model

Image, name - `convert_image/Cast`, shape - `[1x512x512x3]`, format is `[BxHxWxC]`, where:

- `B` - batch size
- `H` - height
- `W` - width
- `C` - channel

Channel order is `RGB`.

### Converted Model

Image, name - `convert_image/Cast/placeholder_port_0`, shape - `[1x3x512x512]`, format is `[BxCxHxW]`, where:

- `B` - batch size
- `C` - channel
- `H` - height
- `W` - width

Channel order is `BGR`.

## Output

### Original Model

The array of summary detection information, name: `detections`, shape: [1, 7, N], where N is the number of detected
bounding boxes. For each detection, the description has the format:
[`image_id`, `y_min`, `x_min`, `y_max`, `x_max`, `confidence`, `label`],
where:

- `image_id` - ID of the image in the batch
- (`x_min`, `y_min`) - coordinates of the top left bounding box corner
- (`x_max`, `y_max`) - coordinates of the bottom right bounding box corner
- `confidence` - confidence for the predicted class
- `label` - predicted class ID, starting from 1

### Converted Model

The array of summary detection information, name: `detections`, shape: [1, 1, N, 7], where N is the number of detected
bounding boxes. For each detection, the description has the format:
[`image_id`, `label`, `conf`, `x_min`, `y_min`, `x_max`, `y_max`],
where:

- `image_id` - ID of the image in the batch
- `label` - predicted class ID, starting from 0
- `conf` - confidence for the predicted class
- (`x_min`, `y_min`) - coordinates of the top left bounding box corner (coordinates stored in normalized format, in range [0, 1])
- (`x_max`, `y_max`) - coordinates of the bottom right bounding box corner (coordinates stored in normalized format, in range [0, 1])

## Legal Information

The original model is distributed under the
[Apache License, Version 2.0](https://raw.githubusercontent.com/google/automl/master/LICENSE).
A copy of the license is provided in [APACHE-2.0-TF-AutoML.txt](../licenses/APACHE-2.0-TF-AutoML.txt).
113 changes: 113 additions & 0 deletions models/public/efficientdet-d0-tf/model.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Copyright (c) 2020 Intel Corporation
#
# 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
#
# http://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.

description: >-
The "efficientdet-d0" model is one of the EfficientDet <https://arxiv.org/abs/1911.09070>
models designed to perform object detection. This model was pretrained in TensorFlow*.
All the EfficientDet models have been pretrained on the MSCOCO* image database.
For details about this family of models, check out the Google AutoML repository
<https://github.com/google/automl/tree/master/efficientdet>.
task_type: detection
files:
- name: efficientdet-d0.tar.gz
size: 28828936
sha256: 74794c937aa1fa2f559c2393d22b251b1f7135a49b108bd0414bc4f4800ca15d
source: https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d0.tar.gz
- name: model_inspect.py
size: 20388
sha256: 6c68fe02f10d62dd87c2fc550b41c3df5cce52f0449be22e0699fbf209e3cbc1
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/model_inspect.py
- name: hparams_config.py
size: 13750
sha256: a7f9a3215a864e2f393addefc997ceba1d78ccba4909390310c453e391c9710b
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/hparams_config.py
- name: inference.py
size: 25076
sha256: 1f0a633de186f9b786979ead00921b910e9853bb33717328f76c1f71af8be997
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/inference.py
- name: dataloader.py
size: 19251
sha256: 5e4bdfc1a746dd2fffe6a0d7bd83ea6422b2883fce5e8e7fb7ed381e919c11a9
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/dataloader.py
- name: nms_np.py
size: 11404
sha256: e72ffbab850f9a267f9cc5ae480a4ee0936402fd109dfd3c2fa7b5644e71245f
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/nms_np.py
- name: utils.py
size: 25677
sha256: eb68091efcf989a908225c2af6d7f632f90c6602659ab06dea628cbdcabdd403
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/utils.py
- name: keras/efficientdet_keras.py
size: 32414
sha256: 4b60b29aabae4365bb9d77b40698a974de9fd4d998f9be94df12b184c0e09ca9
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/keras/efficientdet_keras.py
- name: backbone/efficientnet_builder.py
size: 11609
sha256: 868b9b4cd06c39e1ec15ea1005c36771676f30003c034a0bed4d06e00932905c
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/backbone/efficientnet_builder.py
- name: backbone/efficientnet_model.py
size: 27419
sha256: 0a488e70c46bfa6d98fec66b4c518e0b3a25eedd8ca836123f4ef335dd12bf0c
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/backbone/efficientnet_model.py
- name: backbone/backbone_factory.py
size: 2963
sha256: 3babe95f1bd104fdb1f54e49e68e2a12478933058d6a09c2a46401e80fab06c9
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/backbone/backbone_factory.py
- name: keras/anchors.py
size: 9175
sha256: a88000a453e1ec1194cff2155a1148ef1c2ca87ad563cff2f412f1a597c3ffd7
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/keras/anchors.py
- name: keras/util_keras.py
size: 2198
sha256: 81e21202054018d7616ab1d0f41eceaf8b4e31a6d6ee88cb53c251abea9fa582
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/keras/util_keras.py
- name: keras/fpn_configs.py
size: 6120
sha256: 245cdd3308141fbb6d2b04b850d45fabb56a0f8ac74c857c7dd0d38238664f0d
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/keras/fpn_configs.py
- name: keras/postprocess.py
size: 17677
sha256: 7ca776128887a813089dfc81a61cd4e82b4c3add100a5bafc1951f7dedd1fb4b
source: https://raw.githubusercontent.com/google/automl/341af7d4da7805c3a874877484e133f33c420ec5/efficientdet/keras/postprocess.py
postprocessing:
# disable imports that aren't needed for this model and code that uses them
- $type: regex_replace
file: inference.py
pattern: '(import det_model_fn|from (keras import label_util|visualize))'
replacement: '# \g<0>'
- $type: regex_replace
file: backbone/backbone_factory.py
pattern: 'from backbone import efficientnet_lite_builder'
replacement: '# \g<0>'
- $type: regex_replace
file: dataloader.py
pattern: 'from (object_detection|keras)'
replacement: '# \g<0>'
- $type: regex_replace
file: keras/anchors.py
pattern: 'from object_detection'
replacement: '# \g<0>'

- $type: unpack_archive
format: gztar
file: efficientdet-d0.tar.gz
model_optimizer_args:
- --input_shape=[1,512,512,3]
- --input=convert_image/Cast
- --reverse_input_channels
- --input_model=$conv_dir/efficientdet-d0_saved_model/efficientdet-d0_frozen.pb
- --output=concat,concat_1
- --transformations_config=$mo_dir/extensions/front/tf/automl_efficientdet.json
framework: tf
license: https://raw.githubusercontent.com/google/automl/master/LICENSE
38 changes: 38 additions & 0 deletions models/public/efficientdet-d0-tf/pre-convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3

# Copyright (c) 2020 Intel Corporation
#
# 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
#
# http://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.

import argparse
import subprocess
import sys

from pathlib import Path

def main():
parser = argparse.ArgumentParser()
parser.add_argument('input_dir', type=Path)
parser.add_argument('output_dir', type=Path)
args = parser.parse_args()

subprocess.run([sys.executable, '--',
str(args.input_dir / 'model_inspect.py'),
"--runmode=saved_model",
"--model_name=efficientdet-d0",
"--ckpt_path={}".format(args.input_dir / "efficientdet-d0"),
"--saved_model_dir={}".format(args.output_dir / "efficientdet-d0_saved_model")
], check=True)

if __name__ == '__main__':
main()
23 changes: 23 additions & 0 deletions models/public/efficientdet-d1-tf/accuracy-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
models:
- name: efficientdet-d1-tf
launchers:
- framework: dlsdk
adapter: ssd
datasets:
- name: ms_coco_detection_90_class_without_backgound
preprocessing:
- type: resize
aspect_ratio_scale: fit_to_window
size: 640
- type: padding
size: 640
pad_type: right_bottom

postprocessing:
- type: faster_rcnn_postprocessing_resize
size: 640
- type: shift_labels
offset: 1

metrics:
- type: coco_precision
86 changes: 86 additions & 0 deletions models/public/efficientdet-d1-tf/efficientdet-d1-tf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# efficientdet-d1-tf

## Use Case and High-Level Description

The "efficientdet-d1" model is one of the [EfficientDet](https://arxiv.org/abs/1911.09070)
models designed to perform object detection. This model was pretrained in TensorFlow*.
All the EfficientDet models have been pretrained on the MSCOCO* image database.
For details about this family of models, check out the Google AutoML [repository]
(https://github.com/google/automl/tree/master/efficientdet).

## Example

## Specification

| Metric | Value |
|-------------------|-----------------|
| Type | Object detection|
| GFLOPs | 0.819 |
| MParams | 5.268 |
| Source framework | TensorFlow\* |

## Accuracy

| Metric | Converted model |
| ------ | --------------- |
| coco_precision | 37.54%|

## Performance

## Input

### Original Model

Image, name - `convert_image/Cast`, shape - `[1x640x640x3]`, format is `[BxHxWxC]`, where:

- `B` - batch size
- `H` - height
- `W` - width
- `C` - channel

Channel order is `RGB`.

### Converted Model

Image, name - `convert_image/Cast/placeholder_port_0`, shape - `[1x3x640x640]`, format is `[BxCxHxW]`, where:

- `B` - batch size
- `C` - channel
- `H` - height
- `W` - width

Channel order is `BGR`.

## Output

### Original Model

The array of summary detection information, name: `detections`, shape: [1, 7, N], where N is the number of detected
bounding boxes. For each detection, the description has the format:
[`image_id`, `y_min`, `x_min`, `y_max`, `x_max`, `confidence`, `label`],
where:

- `image_id` - ID of the image in the batch
- (`x_min`, `y_min`) - coordinates of the top left bounding box corner
- (`x_max`, `y_max`) - coordinates of the bottom right bounding box corner
- `confidence` - confidence for the predicted class
- `label` - predicted class ID, starting from 1

### Converted Model

The array of summary detection information, name: `detections`, shape: [1, 1, N, 7], where N is the number of detected
bounding boxes. For each detection, the description has the format:
[`image_id`, `label`, `conf`, `x_min`, `y_min`, `x_max`, `y_max`],
where:

- `image_id` - ID of the image in the batch
- `label` - predicted class ID, starting from 0
- `conf` - confidence for the predicted class
- (`x_min`, `y_min`) - coordinates of the top left bounding box corner (coordinates stored in normalized format, in range [0, 1])
- (`x_max`, `y_max`) - coordinates of the bottom right bounding box corner (coordinates stored in normalized format, in range [0, 1])

## Legal Information

The original model is distributed under the
[Apache License, Version 2.0](https://raw.githubusercontent.com/google/automl/master/LICENSE).
A copy of the license is provided in [APACHE-2.0-TF-AutoML.txt](../licenses/APACHE-2.0-TF-AutoML.txt).
Loading

0 comments on commit 5944695

Please sign in to comment.