Tensorflow Pretrained
Preprocessing Images
from tensorflow.python.keras.preprocessing.image import load_img
imgs = [load_img(img, target_size=(height, width), for img in imgs)]import numpy as np
from tensorflow.python.keras.preprocessing.image import img_to_array
img_array = np.array([img_to_array(img) for img in imgs])from tensorflow.python.keras.applications.resnet50 import preprocess_input
output = preprocess_input(img_array)Predicting using Pretrained Models
from tensorflow.python.keras.applications import ResNet50
my_model = ResNet50(weights='../input/resnet50/resnet50_weights_tf_dim_ordering_tf_kernels.h5')
test_data = read_and_prep_images(img_paths)
preds = my_model.predict(test_data)Last updated