automl icon indicating copy to clipboard operation
automl copied to clipboard

Is there no tf.image.non_max_suppression_with_scores in tensorflow 1.14 ?

Open Jupanlee opened this issue 6 years ago • 10 comments

Jupanlee avatar Apr 22 '20 08:04 Jupanlee

No description provided.

replace tf.image.non_max_suppression_with_scores with tf.image.non_max_suppression for lower tf version.

fsx950223 avatar Apr 22 '20 08:04 fsx950223

After I replace, I encouter the following problem, infer_efficientdet.py is one part of inference.py
File "infer_efficientdet.py", line 606, in driver.build() File "infer_efficientdet.py", line 388, in build max_boxes_to_draw=max_boxes_to_draw) File "infer_efficientdet.py", line 198, in det_post_process disable_pyfun=params.get('disable_pyfun')) File "/notebooks/body_detection/person_decoration/automl-master/efficientdet/push_to_gitlab/anchors.py", line 585, in generate_detections max_boxes_to_draw=max_boxes_to_draw) File "/notebooks/body_detection/person_decoration/automl-master/efficientdet/push_to_gitlab/anchors.py", line 323, in _generate_detections_tf name=None) File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 477, in iter "Tensor objects are only iterable when eager execution is " TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

Jupanlee avatar Apr 22 '20 11:04 Jupanlee

the function det_post_process is called in the function build() of ServingInference.py may be the reason

Jupanlee avatar Apr 22 '20 11:04 Jupanlee

top_detection_idx = tf.image.non_max_suppression(
        boxes,
        scores,
        max_boxes_to_draw,
        iou_threshold=iou_threshold,
        score_threshold=min_score_thresh)
scores = tf.gather(scores, top_detection_idx)

fsx950223 avatar Apr 22 '20 11:04 fsx950223

Thank you!!! And there is not tf.repeat in version 1.14. which function do you use for tf.repeat in version 1.14.

detections = tf.stack([ tf.cast(tf.repeat(image_id, tf.size(top_detection_idx)), tf.float32), boxes[:, 0] * image_scale, boxes[:, 1] * image_scale, height * image_scale, width * image_scale, scores, tf.cast(tf.gather(classes, top_detection_idx) + 1, tf.float32) ], axis=1) return detections

Jupanlee avatar Apr 22 '20 12:04 Jupanlee

Thank you!!! And there is not tf.repeat in version 1.14. which function do you use for tf.repeat in version 1.14.

detections = tf.stack([ tf.cast(tf.repeat(image_id, tf.size(top_detection_idx)), tf.float32), boxes[:, 0] * image_scale, boxes[:, 1] * image_scale, height * image_scale, width * image_scale, scores, tf.cast(tf.gather(classes, top_detection_idx) + 1, tf.float32) ], axis=1) return detections

I only use tf1.15+

fsx950223 avatar Apr 22 '20 12:04 fsx950223

Thank you!!!!!!!!!!!!

Jupanlee avatar Apr 22 '20 12:04 Jupanlee

Thank you!!! And there is not tf.repeat in version 1.14. which function do you use for tf.repeat in version 1.14.

detections = tf.stack([ tf.cast(tf.repeat(image_id, tf.size(top_detection_idx)), tf.float32), boxes[:, 0] * image_scale, boxes[:, 1] * image_scale, height * image_scale, width * image_scale, scores, tf.cast(tf.gather(classes, top_detection_idx) + 1, tf.float32) ], axis=1) return detections

tf.tile(image_id, [tf.size(top_detection_idx)])

fsx950223 avatar Apr 22 '20 12:04 fsx950223

With the help of you, I have solved the problem. Thank you!!!!

Jupanlee avatar Apr 22 '20 13:04 Jupanlee

@Jupanlee Hello, TypeError tensor objects are only iterable when eager execution is enabled. To iterate over this tensorf use tf.map_fn, do you have the problem when you replace tf.image.non_max_suppression_with_score with tf.image.non_max_suppression?

I use tf-cpu1.14.0

vicwer avatar Apr 23 '20 06:04 vicwer