Unable to synchronously open file
When I try to load my model.h5 file it returns this error on the deploy logs. I am deploying a Flask app API and all other routes have been working fine except this one.
Solution:Jump to solution
you would have to store the file in an S3 storage bucket, then have your code download the model file for you
8 Replies
Project ID:
03f47d59-4b7c-49e0-b503-80f3807edfca
03f47d59-4b7c-49e0-b503-80f3807edfca
this is the error shown in logs
[2023-11-28 13:17:57,941] ERROR in app: Exception on /skan [POST]
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1455, in wsgi_app
response = self.full_dispatch_request()
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 869, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 176, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 867, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 852, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/app/main.py", line 147, in skan
model = load_model('model.h5')
File "/opt/venv/lib/python3.8/site-packages/keras/src/saving/saving_api.py", line 238, in load_model
return legacy_sm_saving_lib.load_model(
File "/opt/venv/lib/python3.8/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/opt/venv/lib/python3.8/site-packages/h5py/_hl/files.py", line 562, in __init__
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
File "/opt/venv/lib/python3.8/site-packages/h5py/_hl/files.py", line 235, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 102, in h5py.h5f.open
OSError: Unable to synchronously open file (file signature not found)
how big is the model file?
hi, i manually created the model architecture at the api and now i'm trying to only load the model weights, which is 172MB. i used git lfs to mount it on github
just as I thought, railway does not support pulling files from git lfs
Solution
you would have to store the file in an S3 storage bucket, then have your code download the model file for you
I recommend cloudflare r2
ill check on that, thanks