Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No file or directory found at spiral_keras_model.h5 #19906

Open
project-set opened this issue Jun 23, 2024 · 1 comment
Open

No file or directory found at spiral_keras_model.h5 #19906

project-set opened this issue Jun 23, 2024 · 1 comment

Comments

@project-set
Copy link

hello, please help me because the Keras Spiral H5 model is not found even though I have installed TensorFlow

spiral h5

import os

file_path = 'path/to/spiral_keras_model.h5'
print(os.path.exists(file_path))

False

model = load_model('spiral_keras_model.h5')
class_names = ['1 Healthy-Spiral', '0 Parkinsons-Spiral'] # Define your actual class names

**---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[22], line 1
----> 1 model = load_model('spiral_keras_model.h5')
2 class_names = ['1 Healthy-Spiral', '0 Parkinsons-Spiral']

File ~\anaconda3\Lib\site-packages\keras\src\saving\saving_api.py:262, in load_model(filepath, custom_objects, compile, safe_mode, **kwargs)
254 return saving_lib.load_model(
255 filepath,
256 custom_objects=custom_objects,
257 compile=compile,
258 safe_mode=safe_mode,
259 )
261 # Legacy case.
--> 262 return legacy_sm_saving_lib.load_model(
263 filepath, custom_objects=custom_objects, compile=compile, **kwargs
264 )

File ~\anaconda3\Lib\site-packages\keras\src\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb

File ~\anaconda3\Lib\site-packages\keras\src\saving\legacy\save.py:234, in load_model(filepath, custom_objects, compile, options)
232 if isinstance(filepath_str, str):
233 if not tf.io.gfile.exists(filepath_str):
--> 234 raise IOError(
235 f"No file or directory found at {filepath_str}"
236 )
238 if tf.io.gfile.isdir(filepath_str):
239 return saved_model_load.load(
240 filepath_str, compile, options
241 )

OSError: No file or directory found at spiral_keras_model.h5**

@mehtamansi29
Copy link
Collaborator

mehtamansi29 commented Jun 25, 2024

Hi @project-set -

As per the code snippet shared by you, you are getting False for this line print(os.path.exists(file_path)). It means the model file_path is not correct. Please correct model file_path and try to load the h5 model in tensorflow 2.15 or keras 2.15 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants