我https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3
用来提取图像特征向量。但是,当谈到如何在将图像通过模块之前对其进行预处理时,我感到很困惑。
根据相关的Github解释,据说应该做以下事情:
image_path = "path/to/the/jpg/image"
image_string = tf.read_file(image_path)
image = tf.image.decode_jpeg(image_string, channels=3)
image = tf.image.convert_image_dtype(image, tf.float32)
# All other transformations (during training), in my case:
image = tf.random_crop(image, [224, 224, 3])
image = tf.image.random_flip_left_right(image)
# During testing:
image = tf.image.resize_image_with_crop_or_pad(image, 224, 224)
但是,使用上述转换,我得到的结果表明可能有问题。此外,Resnet 论文说图像应该通过以下方式进行预处理:
从图像或其水平翻转中随机采样 224×224 裁剪,减去每个像素的平均值......
我不太明白这是什么意思。有人可以指出我正确的方向吗?
期待您的解答!