def get_fix_offset(h, w, crop_height, crop_width):
crop_offsets = []
height_off = (h - crop_height) / 4
width_off = (w - crop_width) / 4
crop_offsets.append(tf.stack([0, 0]))
crop_offsets.append(tf.stack([0, tf.to_int32(4 * width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(4 * height_off), 0]))
crop_offsets.append(tf.stack([tf.to_int32(4 * height_off), tf.to_int32(4 * width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(2 * height_off), tf.to_int32(2 * width_off)]))
# more fix crop
crop_offsets.append(tf.stack([0, tf.to_int32(2 * width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(4 * height_off), tf.to_int32(2 * width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(2 * height_off), 0]))
crop_offsets.append(tf.stack([tf.to_int32(2 * height_off), tf.to_int32(4 * width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(height_off), tf.to_int32(width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(height_off), tf.to_int32(3 * width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(3 * height_off), tf.to_int32(width_off)]))
crop_offsets.append(tf.stack([tf.to_int32(3 * height_off), tf.to_int32(3 * width_off)]))
crop_offsets = tf.stack(crop_offsets)
return crop_offsets
评论列表
文章目录