giovedì 9 gennaio 2020

Predizione classificazione immagini con Tensorflow da modelli .h5

In un esempio precedente avevo usato il modello .tflite per fare predizione di classificazione immagine.

Il modello e' stato creato da un train di Inception

============================================================

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

import sys

import tensorflow as tf

import tensorflow_hub as hub

from keras.models import load_model

model = tf.keras.models.load_model('incept.h5', custom_objects={'KerasLayer':hub.KerasLayer})
#print(model.get_config())
from keras.preprocessing import image
img = image.load_img(sys.argv[1])# , target_size=(299,299,3))
img  = image.img_to_array(img)
img  = img.reshape((1,) + img.shape)
img  = img/255
build_input_shape = img.reshape(-1,299,299,3)
#print (build_input_shape)
img_class=model.predict_classes(img) 
print (sys.argv[1])
print(img_class) 

Nessun commento:

Posta un commento

LLama3 Anita

A seguito di questo post ho provato a vedere ho provato a vedere cosa accadeva ad utilizzare un modello specifico per la lingua italiana in...