Closed
Description
Hi guys, how are you?
I'm trying to load my trained model but I'm getting the following error:File not found: filepath=modelo\model_74.keras. Please ensure the file is an accessible .keras
zip file.
Keras Version: 3.0.5
Tensorflow Version: 2.16.1
Code I'm using to load the model
from tensorflow.keras.utils import CustomObjectScope
from tensorflow.keras.models import load_model
from keras import backend as K # Estrutura de manipulação de tensores simbólicos
""" IoU """
def iou(y_true, y_pred, smooth=1):
intersection = K.sum(K.abs(y_true * y_pred), axis=[1,2,3])
union = K.sum(y_true,[1,2,3])+K.sum(y_pred,[1,2,3])-intersection
iou = K.mean((intersection + smooth) / (union + smooth), axis=0) # Média de um tensor, ao longo do eixo especificado
return iou
""" Dice Coefficient """
def dice_coef(y_true, y_pred, smooth=1):
intersection = K.sum(y_true * y_pred, axis=[1,2,3])
union = K.sum(y_true, axis=[1,2,3]) + K.sum(y_pred, axis=[1,2,3])
return K.mean( (2. * intersection + smooth) / (union + smooth), axis=0)
""" Dice Coefficient Loss """
def dice_coef_loss(y_true, y_pred):
return 1 - dice_coef(y_true, y_pred)
scope = {'iou': iou, 'dice_coef': dice_coef, 'dice_coef_loss': dice_coef_loss}
path_model = 'modelo/model_74.keras'
with CustomObjectScope(scope):
modelo = load_model(Path(path_model))
I tried other PATHS:
path_model = './modelo/model_74.keras'
or
path_model = 'modelo//model_74.keras'
or
path_model = './/modelo//model_74.keras'
or
path_model = '//modelo//model_74.keras'