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的用法
本文介绍使用TensorFlow进行图片预处理的方法,包括读取图片、调整尺寸、随机裁剪等步骤,为深度学习任务准备训练数据。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.9
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

被折叠的 条评论
为什么被折叠?



