-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Environment
- OS: [Windows 11]
- Python version: [Python version 3.10.15]
- TensorFlow version: [TensorFlow version 2.8.0 CPU]
- keras version :[2.10.0]
- h5py version: [3.13]
Description
I'm encountering an error when trying to load Keras model weights with the following error message: OSError: Unable to synchronously open file (file signature not found)
Error Details
2025-03-04 09:25:53.201848: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
test_drawing.py:None (test_drawing.py)
test_drawing.py:52: in <module>
recognizer_dim.model.load_weights(dim_model)
E:\ProgramData\miniconda3\lib\site-packages\keras\utils\traceback_utils.py:70: in error_handler
raise e.with_traceback(filtered_tb) from None
E:\ProgramData\miniconda3\lib\site-packages\h5py\_hl\files.py:564: in **init**
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
E:\ProgramData\miniconda3\lib\site-packages\h5py\_hl\files.py:238: in make_fid
fid = h5f.open(name, flags, fapl=fapl)
h5py\\_objects.pyx:54: in h5py._objects.with_phil.wrapper
???
h5py\\_objects.pyx:55: in h5py._objects.with_phil.wrapper
???
h5py\\h5f.pyx:102: in h5py.h5f.open
???
OSError: Unable to synchronously open file (file signature not found)
File Information
The model files in question:
recognizer_dimensions_2.keras: 68.850 KBrecognizer_dimensions_2.txt: 1 KBrecognizer_gdts.keras: 68.852 KBrecognizer_gdts.txt: 1 KB
Code to Reproduce
recognizer_dim = Recognizer(alphabet=alphabet_dim)
recognizer_dim.model.load_weights(dim_model) # Error occurs hereSolutions Attempted
I've tried several approaches to resolve this issue without success:
- Using different versions of TensorFlow and h5py
- Using
tf.keras.models.load_modelinstead ofload_weights - Attempting to repair the file header (ensuring it starts with the H5 signature)
- Converting to SavedModel format
- Checking file permissions and integrity
Questions
- Are there any known compatibility issues with the file format?
- Is there an effective way to repair corrupted .keras files?
- Are there alternative loading methods that might work in this situation?
Metadata
Metadata
Assignees
Labels
No labels