Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move TF OD API docs to code + several fixes for TF OD API models conversion #7377

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
878b882
Refactored code, updated comments and documentation related to TF OD …
lazarevevgeny Sep 2, 2021
4319c8c
Improved MO messages related to pre-processor block removal during co…
lazarevevgeny Sep 2, 2021
114cd74
Updated TF OD API transformation and documentation for SSD models
lazarevevgeny Sep 4, 2021
81102f6
Updated comments and documentation for the ObjectDetectionAPIMaskRCNN…
lazarevevgeny Sep 4, 2021
21091e5
Updated comments and documentation for the ObjectDetectionAPIMaskRCNN…
lazarevevgeny Sep 4, 2021
33fb103
Updated comments and documentation for the ObjectDetectionAPIPSROIPo…
lazarevevgeny Sep 4, 2021
2499e73
Updated comments and documentation for the ObjectDetectionAPIProposal…
lazarevevgeny Sep 4, 2021
5690411
Updated comments and documentation for the ObjectDetectionAPIDetecti…
lazarevevgeny Sep 5, 2021
8993e8f
Merge remote-tracking branch 'upstream/master' into tf_od_api_docs_in…
lazarevevgeny Sep 5, 2021
8423bad
Minor code style fixes
lazarevevgeny Sep 5, 2021
6a7b590
Fixed unit tests for ObjectDetectionAPIPreprocessor2Replacement trans…
lazarevevgeny Sep 6, 2021
3002e73
Improved unit test for pipeline.config parser. Fixed very long bug wi…
lazarevevgeny Sep 6, 2021
0a3e060
Merge remote-tracking branch 'upstream/master' into tf_od_api_docs_in…
lazarevevgeny Sep 6, 2021
fb0eb79
Code style fixes
lazarevevgeny Sep 6, 2021
8171633
Get rid of "coordinates_swap_method" parameter in the JSON configurat…
lazarevevgeny Sep 6, 2021
2c1cbf0
Code style fixes and minor refactoring
lazarevevgeny Sep 6, 2021
aa78115
Simplied code related to swapping Proposal coordinates
lazarevevgeny Sep 7, 2021
72b829b
Merge remote-tracking branch 'upstream/master' into tf_od_api_docs_in…
lazarevevgeny Sep 7, 2021
8f73b4b
Removed incorrectly removed code
lazarevevgeny Sep 7, 2021
e5ad6f7
Merge remote-tracking branch 'upstream/master' into tf_od_api_docs_in…
lazarevevgeny Sep 7, 2021
52b1af0
Fixed code review comments about the code comments
lazarevevgeny Sep 7, 2021
a2969e4
Merge remote-tracking branch 'upstream/master' into tf_od_api_docs_in…
lazarevevgeny Sep 7, 2021
1eeec34
Merge remote-tracking branch 'upstream/master' into tf_od_api_docs_in…
lazarevevgeny Sep 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

997 changes: 584 additions & 413 deletions model-optimizer/extensions/front/tf/ObjectDetectionAPI.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
{
"custom_attributes": {
"clip_before_nms": true,
"clip_after_nms": false,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": false
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": true,
"clip_after_nms": false,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": false
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"background_label_id": 0,
"coordinates_swap_method": "swap_weights"
"background_label_id": 0
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"background_label_id": 0,
"coordinates_swap_method": "swap_weights"
"background_label_id": 0
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": true,
"clip_after_nms": false,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": false
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
{
"custom_attributes": {
"clip_before_nms": true,
"clip_after_nms": false,
"coordinates_swap_method": "swap_weights"
"clip_after_nms": false
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"background_label_id": 0,
"coordinates_swap_method": "swap_weights"
"background_label_id": 0
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"background_label_id": 0,
"coordinates_swap_method": "swap_weights"
"background_label_id": 0
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"include_inputs_to_sub_graph": true,
Expand Down
1 change: 0 additions & 1 deletion model-optimizer/extensions/front/tf/rfcn_support.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"custom_attributes": {
"clip_before_nms": true,
"clip_after_nms": false,
"coordinates_swap_method": "add_convolution",
"swap_proposals": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "add_convolution"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "add_convolution"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
{
"custom_attributes": {
"clip_before_nms": false,
"clip_after_nms": true,
"coordinates_swap_method": "add_convolution"
"clip_after_nms": true
},
"id": "ObjectDetectionAPIDetectionOutputReplacement",
"inputs": [
Expand Down
39 changes: 0 additions & 39 deletions model-optimizer/mo/front/tf/graph_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import collections
import logging as log
from typing import Dict

import numpy as np
Expand Down Expand Up @@ -52,43 +50,6 @@ def create_op_with_const_inputs(graph: Graph, op: callable, port_value_dict: Dic
return node


def mark_squeeze_reshape_concat_before_detection_output(start_nodes: list):
"""
The function looks for Reshape, Concat and Squeeze ops after the 'start_nodes' with 4D output and marks them with
proper attributes to infer them in original NHWC layout. This is a case of the TensorFlow Object Detection API
models for the SSD heads output which produces 4D tensor with bounding box deltas.
:param start_nodes: list of nodes to start search from.
:return: None
"""
q = collections.deque()
q.extend(start_nodes)
while len(q) != 0:
cur_node = q.popleft()
if cur_node.has_valid('type'):
if cur_node.soft_get('type') == 'DetectionOutput': # do not go beyond the DetectionOutput node
continue
# the input to Reshape comes from Convolution so it will be converted from NCHW to NHWC layout in the
# InsertLayoutPropagationTransposes transformation. But the output should be kept in the original layout
if cur_node.soft_get('type') == 'Reshape' and len(cur_node.out_port(0).data.get_shape()) == 4:
mark_output_as_in_correct_layout(cur_node, 0)

# Concat should be inferred in the original layout so the input with concatenation axis should not be
# updated from NHWC to NCHW layout
if cur_node.soft_get('type') == 'Concat' and len(cur_node.out_port(0).data.get_shape()) == 4:
cur_node.in_port(1).__setattr__('input_permutation', None)
cur_node['nchw_layout'] = True
cur_node.out_node(0)['nchw_layout'] = True

# Squeeze should be inferred in the original layout so the input with squeeze axis should not be updated
# from NHWC to NCHW layout. The input is marked as in correct layout to prevent from inserting Transpose
# from NHWC to NCHW.
if cur_node.soft_get('type') == 'Squeeze' and len(cur_node.in_port(0).data.get_shape()) == 4:
cur_node.in_port(1).__setattr__('input_permutation', None)
mark_input_as_in_correct_layout(cur_node, 0)

[q.append(port.node) for port in cur_node.out_port(0).get_destinations()]


def add_convolution_to_swap_xy_coordinates(graph: Graph, input_node: Node, coordinates_size: int):
"""
The function add convolution node after the node 'input_node' to swap xy coordinates of the boxes produced
Expand Down
Loading