tensorflow / tensorflow/models

Cannot do inference from the saved model for the model centernet_mobilenetv2fpn_512x512_coco17_od

Open
#10,700 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

models:research type:bug
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

Prerequisites

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

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

1. The entire URL of the file you are using

http://download.tensorflow.org/models/object_detection/tf2/20210210/centernet_mobilenetv2fpn_512x512_coco17_od.tar.gz

2. Describe the bug

detec_fn fails on an inference for the input tensor
image

3. Steps to reproduce

# Download the saved model and put it into models/research/object_detection/test_data/
!wget http://download.tensorflow.org/models/object_detection/tf2/20210210/centernet_mobilenetv2fpn_512x512_coco17_od.tar.gz
!tar -xf centernet_mobilenetv2fpn_512x512_coco17_od.tar.gz
!mv centernet_mobilenetv2_fpn_od/ models/research/object_detection/test_data/

start_time = time.time()
tf.keras.backend.clear_session()
detect_fn = tf.saved_model.load('models/research/object_detection/test_data/centernet_mobilenetv2_fpn_od//saved_model/')
end_time = time.time()
elapsed_time = end_time - start_time
print('Elapsed time: ' + str(elapsed_time) + 's')

import time

image_dir = 'models/research/object_detection/test_images'

elapsed = []
for i in range(2):
  image_path = os.path.join(image_dir, 'image' + str(i + 1) + '.jpg')
  image_np = load_image_into_numpy_array(image_path)
  input_tensor = np.expand_dims(image_np, 0)
  start_time = time.time()
  detections = detect_fn(input_tensor)
  end_time = time.time()
  elapsed.append(end_time - start_time)

4. Expected behavior

I expected to be able to detect boxes directly from a saved model

5. Additional context

I ran the model both locally. and also using the colab tutorial https://colab.research.google.com/github/tensorflow/models/blob/master/research/object_detection/colab_tutorials/inference_from_saved_model_tf2_colab.ipynb#scrollTo=vukkhd5-9NSL with the mobilenet model and error remains the same

6. System information

I ran from the colab tutorial
Tensorflow version v2.9.0-18-gd8ce9f9c301 2.9.1 https://colab.research.google.com/github/tensorflow/models/blob/master/research/object_detection/colab_tutorials/inference_from_saved_model_tf2_colab.ipynb#scrollTo=vukkhd5-9NSL

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Mobile device name if the issue happens on a mobile device:
  • TensorFlow installed from (source or binary):
  • TensorFlow version (use command below):
  • Python version:
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the saved model at models/research/object_detection/test_data/centernet_mobilenetv2_fpn_od/saved_model/ using the inference_from_saved_model_tf2_colab.ipynb workflow and the reported detect_fn call. Check the saved model loading and input tensor path first; the issue is done when inference returns detections for the test images.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.