コード例 #1
0
 def get_image_vgg(self, path):
     """Return a handle to the image itself, and a numpy array of its pixels to input the network."""
     img = image.load_img(path, target_size=(224, 224))
     x = image.img_to_array(img)
     x = np.expand_dims(x, axis=0)
     x = preprocess_input_vgg(x)
     return img, x
コード例 #2
0
def img_encode(filepath):
  img_width, img_height = 254, 254
  try:
    img = image.load_img(filepath, target_size=(img_width, img_height))
  except:
    return False, False
  x = image.img_to_array(img)
  x = np.expand_dims(x, axis=0)
  x = preprocess_input_vgg(x)
  return img, x
コード例 #3
0
def get_image_vgg(path):
    img = image.load_img(path, target_size=model.input_shape[1:3])
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input_vgg(x)
    return img, x