import tensorflow as tf
def my_1D_image_crop_and_resize_fake(feature_map, boxes, box_ind, crop_size,method):
'''
:param feature_map: [batch, width, channels]
:param boxes: [batch, num_boxes, (x1, x2)]
:param box_ind:[batch,num_boxes]
:param crop_size:[crop_width]
:return:[num_boxes, 1, crop_width, depth]
'''
# convert the 1D feature-map [batch_size,width,deepth] to 2D feature-map [batch_size,heigth=2,width,deepth]
# adapte the tf.image.crop_and_resize function
feature_map = tf.expand_dims(feature_map, axis=1)
feature_map = tf.tile(feature_map, [1, 2, 1, 1])
# for the same reason, convert the 1D boxes [num_boxes,(x1,x2)] to 2D boxes [num_boxes,(y1,x1,y2,x2)]
num_boxes = tf.shape(boxes)[0]
boxes_zero = tf.expand_dims(tf.ones(shape=(num_boxes)), axis=-1)
y1, y2 = boxes_zero, boxes_zero
x1 = tf.expand_dims(boxes[:, 0], axi
时间序列的tf.image.crop_and_resize伪实现
最新推荐文章于 2022-09-23 17:58:05 发布