Computer Vision News - May 2019

The ResNet architecture: Implementing ResNet50 in Keras A common issue when using a pre-trained model is to adjust the data to the desired input of the network. For example, in the ResNet50 architecture, the input image is a 224x224 image. Moreover, the Keras model requires the input of the model to be of a specific size (dimensions) and normalized. Fortunately, we do not need to implement such preprocessing by ourselves, we can use pre- defined utility functions that are available in keras.application, numpy and keras.preprocessing. We first import them to our environment: Now that we have the image class in our environment, we can load the image from the disk, and with the same command perform resizing of the image to the size of 224x224. Using the image subclass of Keras it looks like this: 23 Focus on Computer Vision News Using Keras Pre-trained Models from keras.preprocessing import image from keras.applications.resnet50 import preprocess_input, decode_predictions import numpy as np img_path = 'ImagePath/ImageName.jpg' img = image.load_img(img_path, target_size=( 224 , 224 ) )

RkJQdWJsaXNoZXIy NTc3NzU=