'How do I remove this error : OSError: Unable to open file (file signature not found)
I am trying to build a crime (in video) classification model using Flask and after I submit a video on my HTML page, the video goes into a trained model. But instead of the output (which is a gif of the video where crime is occurring), I am faced with this error. Other similar errors online say to delete the h5 file stored in .keras folder i.e named as follows:
"C:\Users\Lenovo.keras\models\inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5"
I did delete and installed it again but the error still persists. What can I do now? Does flask only work with h5 models because my model is in .pkl format?
PS C:\Users\Lenovo\Documents\Flask-Video-Classification> python main.py
... #removed some extra CUDA loading statements from here#
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/inception_v3/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5
87916544/87910968 [==============================] - 565s 6us/step
87924736/87910968 [==============================] - 565s 6us/step
* Serving Flask app 'app' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [29/Apr/2022 06:05:30] "GET / HTTP/1.1" 200 -
upload_video filename: CAP_133.mp4
[2022-04-29 06:05:49,492] ERROR in app: Exception on / [POST]
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
File "main.py", line 150, in upload_video
filename = model_predict(filename)
File "main.py", line 60, in model_predict
test_frames = sequence_prediction(video_path)
File "main.py", line 70, in sequence_prediction
sequence_model = tf.keras.models.load_model('model\model3.pkl')
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\h5py\_hl\files.py", line 424, in __init__
fid = make_fid(name, mode, userblock_size,
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\h5py\_hl\files.py", line 190, 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 96, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
127.0.0.1 - - [29/Apr/2022 06:05:49] "POST / HTTP/1.1" 500 -
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
