import tensorflow as tf
with tf.gfile.FastGFile('5.jpg','rb') as f:
img=f.read()
img=tf.image.decode_jpeg(img,channels=3)
img = tf.image.resize_images(img, size=(286, 286))
rand=tf.random_uniform([2], 0, 286 - 256 + 1)
offset = tf.cast(tf.floor(rand), dtype=tf.int32)
r = tf.image.crop_to_bounding_box(img, offset[0], offset[1], 256, 256)
with tf.Session() as sess:
img_,rand_,offset_,r_=sess.run([img,rand,offset,r])
tf.image.crop_to_bounding_box的用法
最新推荐文章于 2023-12-22 18:02:30 发布