Reputation: 25
I restored a pre-trained model for face detection which takes a single image at a time and returns bounding boxes. How can I make it take a batch of images if these images have different sizes?
Upvotes: 0
Views: 1003
Reputation: 16587
You can use tf.image.resize_images
method to achieve this. According to docs tf.image.resize_images
:
Resize images to size using the specified method.
Resized images will be distorted if their original aspect ratio is not the same as size. To avoid distortions see
tf.image.resize_image_with_pad
.
How to use it?
import tensorflow as tf
from tensorflow.python.keras.models import Model
x = Input(shape=(None, None, 3), name='image_input')
resize_x = tf.image.resize_images(x, [32,32])
vgg_model = load_vgg()(resize_x)
model = Model(inputs=x, outputs=vgg_model.output)
model.compile(...)
model.predict(...)
Upvotes: 1