Object_detection_tutorial踩坑记录
环境记录
- Ubuntu
- tensorflow-gpu == 2.4.1
- python == 3.6.13
issue 1
AttributeError: 'AutoTrackable' object has no attribute 'output_shapes'
解决方案
# masking_model.output_shapes 替换为以下
masking_model.signatures['serving_default'].output_shapes
issue 2
在运行maskrcnn模型时出现
TypeError: Cannot interpret 'tf.uint8' as a data type
#~/miniconda3/envs/rcnn/lib/python3.6/site-packages/object_detection/utils/ops.py in reframe_box_masks_to_image_masks(box_masks, boxes, image_height, image_width, resize_method)
resize_method = 'nearest' if box_masks.dtype == tf.uint8 else resize_method # 这一行报错
问题原因
numpy.ndarray无法与tensor比较
解决方案
-
在进入reframe_box_masks_to_image_masks函数之前将box_masks转换为Tensor格式
tf.convert_to_tensor(output_dict[‘detection_masks’])s
-
修改自己环境下的site-packages/object_detection/utils/ops.py的源码
-
import numpy as np
-
resize_method = ‘nearest’ if box_masks.dtype == tf.uint8 else resize_method
修改为
resize_method = ‘nearest’ if box_masks.dtype == np.uint8 else resize_method
-