def network_predict(image):

    image_to_predict = prepare_image(image)

    with graph.as_default():
        prediction = network_model.predict(image_to_predict)

    label = decode_predictions(prediction)

    return label
Esempio n. 2
0
def decode_predictions(*args, **kwargs):
    return vgg16.decode_predictions(*args, **kwargs)
Esempio n. 3
0
    https://colab.research.google.com/drive/1kLOtfIlx8gpJamwqZSXZiJ67Tz7f1Pah
"""
import tensorflow

from keras_preprocessing.image import load_img, img_to_array

from keras_applications.vgg16 import preprocess_input, decode_predictions, VGG16

model = VGG16()

images = load_img("speaker.jpg", target_size=(224, 224))

img_array = img_to_array(images)

img_array

img_array = img_array.reshape(
    (1, img_array.shape[0], img_array.shape[1], img_array.shape[2]))

img_array.shape

image = preprocess_input(img_array)

image

img_pred = model.predict(image)

d_img_pred = decode_predictions(img_pred)

d_img_pred