Skip to content

Mean, std normalization inconsistent #9100

@aabbas90

Description

@aabbas90

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [y] I am using the latest TensorFlow Model Garden release and TensorFlow 2.
  • [y] I am reporting the issue to the correct repository. (Model Garden official or research directory)
  • [y] I checked to make sure that this issue has not been filed already.

1. The entire URL of the file to debug:

https://github.com/tensorflow/models/blob/master/research/object_detection/model_lib_v2.py

2. Describe the bug:

The mean and std normalization of COCO images after preprocessing is still not in normal range in CenterNet. On efficientdet_d0_coco17_tpu-32 behaviour is normal and preprocessing is giving close to 0 mean and 1 std.
I have tried two ways to experiment with CenterNet by using centernet_resnet_v1_50_fpn_512x512_coco17 config from the model zoo (without any checkpoint):

1. By mentioning means and std in config:
Means and stds taken as is from pre-trained model config file in the model zoo:

channel_means: [104.01362025, 114.03422265, 119.9165958 ]
channel_stds: [73.6027665 , 69.89082075, 70.9150767 ]

The mean and std of images after normalization are computed from:

features, labels = data_iterator.next()

features['image'].numpy().mean()
-115.607056
features['image'].numpy().std()
8.1939125

Notice the very negative value of mean and large value of std (batch size: 64).

2. By mean:0, std:1 or not mentioning mean, std in config:

channel_means: [0, 0, 0]
channel_stds: [1, 1, 1]
features['image'].numpy().mean()
-54.237076
features['image'].numpy().std()
80.218575

3. If using efficientdet_d0_coco17_tpu-32 not containing any mean, std info:

features['image'].numpy().mean()
-0.9214938
features['image'].numpy().std()
1.362439

3. Steps to reproduce

Run https://github.com/tensorflow/models/blob/master/research/object_detection/model_main_tf2.py on config file of centernet_resnet_v1_50_fpn_512x512_coco17 from TF model zoo and coco dataset.

4. Expected behavior

Mean and std normalization should be consistent and inner workings documented. After standardization mean and std should be 0 and 1 respectively.

6. System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04): 18.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.3.0
  • Python version: 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    models:researchmodels that come under research directorytype:bugBug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions