tf.image.sample_distorted_bounding_box ValueError

不打扰是莪最后的温柔 提交于 2019-12-26 06:53:45

问题


I am trying to augment existing labeled bounding boxed image for making more object detection training data using the function tf.image.sample_distorted_bounding_box but I keep getting these errors found here. I'm pretty sure my bounding box is set correctly because it works when I draw the bounding box.

img = mpimg.imread('bPawn0.jpg')
img = img.reshape(1,300,300,3)
boxes = [100,88,253,209]
box = np.ones([1,1,4])
for i in range(4):
    box[:,:,i] = boxes[i]/300
box = tf.convert_to_tensor(box, np.float32)

begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(tf.shape(img),bounding_boxes=box)

ValueError: Tried to convert 'min_object_covered' to a tensor and failed. Error: None values not supported.

Any suggestions as to what I am doing wrong here?


回答1:


I'm wondering if this is a bug in the sample_distorted_bounding_box() code, since I don't see a test that doesn't specify that argument to the function explicitly.

Can you try setting that argument explicitly, something like this?

sample_distorted_bounding_box = tf.image.sample_distorted_bounding_box(
    tf.shape(image),
    bounding_boxes=bbox,
    min_object_covered=0.1,
    aspect_ratio_range=[0.75, 1.33],
    area_range=[0.05, 1.0],
    max_attempts=100,
    use_image_if_no_bounding_boxes=True)

https://github.com/tensorflow/models/blob/master/research/inception/inception/image_processing.py#L235



来源:https://stackoverflow.com/questions/47402896/tf-image-sample-distorted-bounding-box-valueerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!