tf.image.crop_to_bounding_box的用法

来源:互联网 发布:房产中介软件xiazaiba 编辑:程序博客网 时间:2024/06/16 08:08
import tensorflow as tfwith 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])