Load h5 file with keras in Foundry code repository

77 Views Asked by At

im trying to load a h5 file into Keras inside a foundry code repository. Here is my code:

import os
import pkg_resources
from keras.models import load_model

def m_path(model_id):
    MODEL_PATH = pkg_resources.resource_filename('myproject', 'models/')
    return os.path.join(MODEL_PATH, f'lstm_{model_id}.h5')

model_path_gnd = m_path('V1')
model_gnd = load_model(model_path_gnd)

Im getting the follwing error:

[module version: 1.1004.0]

ImportError: Filepath looks like a hdf5 file but h5pyis not available. filepath=/app/work-dir/environment/SYMLINKS/site-packages/myproject/models/lstm_gnd.h5

File "/app/work-dir/environment/SYMLINKS/site-packages/keras/src/saving/legacy/save.py", line 244, in load_model raise ImportError( ImportError: Filepath looks like a hdf5 file but h5pyis not available. filepath=/app/work-dir/environment/SYMLINKS/site-packages/myproject/models/lstm_gnd.h5

i have imported the keras and h5py in the yaml file. Does anyone had a similar problem or know the issue?

Thanks and BR

Tellos

i added and removed the h5py in the yaml

0

There are 0 best solutions below