Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unable to synchronously open file (file signature not found) #2

@LovingThresh

Description

@LovingThresh

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 KB
  • recognizer_dimensions_2.txt: 1 KB
  • recognizer_gdts.keras: 68.852 KB
  • recognizer_gdts.txt: 1 KB

Code to Reproduce

recognizer_dim = Recognizer(alphabet=alphabet_dim)
recognizer_dim.model.load_weights(dim_model)  # Error occurs here

Solutions Attempted

I've tried several approaches to resolve this issue without success:

  1. Using different versions of TensorFlow and h5py
  2. Using tf.keras.models.load_model instead of load_weights
  3. Attempting to repair the file header (ensuring it starts with the H5 signature)
  4. Converting to SavedModel format
  5. Checking file permissions and integrity

Questions

  1. Are there any known compatibility issues with the file format?
  2. Is there an effective way to repair corrupted .keras files?
  3. Are there alternative loading methods that might work in this situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions