VQA_Demo
VQA_Demo copied to clipboard
h5py/h5f.pyx in h5py.h5f.open() OSError: Unable to open file (file signature not found)
While running a code, we are receiving below error. Please help me out.
OSError Traceback (most recent call last)
/content/drive/My Drive/VQA_Demo/models/CNN/VGG.py in VGG_16(weights_path) 99 model.add(Dense(1000, activation='softmax')) 100 --> 101 if weights_path: 102 # model.load_weights(weights_path) 103 load_model_legacy(model, weights_path)
/content/drive/My Drive/VQA_Demo/models/CNN/VGG.py in load_model_legacy(model, weight_path) 33 ''' this function is used because the weights in this model 34 were trained with legacy keras. New keras does not support loading these weights ''' ---> 35 36 import h5py 37 f = h5py.File(weight_path, mode='r')
/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py in init(self, name, mode, driver, libver, userblock_size, swmr, **kwds) 310 with phil: 311 fapl = make_fapl(driver, libver, **kwds) --> 312 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) 313 314 if swmr_support:
/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr) 140 if swmr and swmr_support: 141 flags |= h5f.ACC_SWMR_READ --> 142 fid = h5f.open(name, flags, fapl=fapl) 143 elif mode == 'r+': 144 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/h5f.pyx in h5py.h5f.open()
OSError: Unable to open file (file signature not found)
You need to download VGG weights as said in models/CNN/README.md
Replace the get_image_features function with below:
def get_image_model(CNN_weights_file_name): ''' Takes the CNN weights file, and returns the VGG model update with the weights. Requires the file VGG.py inside models/CNN ''' from models.CNN.VGG import VGG_16 image_model = VGG_16(CNN_weights_file_name) image_model.pop() image_model.pop() # this is standard VGG 16 without the last two layers sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True) # one may experiment with "adam" optimizer, but the loss function for # this kind of task is pretty standard image_model.compile(optimizer=sgd, loss='categorical_crossentropy') return image_model
The download link is broken while trying to download vgg16_weights.h5 .
PLEASE CHECK README HERE: https://github.com/iamaaditya/VQA_Demo/tree/master/models/CNN
I have updated the link. Try now.
Thanks and Regards Adi
On Wed, Sep 22, 2021 at 3:04 PM Aryan Gupta @.***> wrote:
The download link is broken while trying to download vgg16_weights.h5 .
PLEASE CHECK README HERE: https://github.com/iamaaditya/VQA_Demo/tree/master/models/CNN
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/iamaaditya/VQA_Demo/issues/25#issuecomment-925224371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOTJ4T6J67LSQOHMOFIT2DUDISCXANCNFSM4GWLVHZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I'm running on Google colab, I'm getting the following error
ValueError: Unknown layer: Merge. Please ensure this object is passed to the custom_objects argument. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.
It occurred while I tried to execute the below code
model_vqa = get_VQA_model(VQA_model_file_name, VQA_weights_file_name)
It happened when I tried load the pretrained json configuration file along with weights file present inside the VGG folder.
-
I checked online but got nothing significant. It suggests I should use the same TF version on which the model is trained. Can you tell me the tensorflow version on which the model is trained upon?
-
Also it is saying to add an argument of custom layer. I don't know the custom layer name with which you trained upon? Please check this out:https://github.com/keras-team/keras/issues/8612
-
Can you tell me the modifications I need to do in the function:
`def get_VQA_model(VQA_model_file_name, VQA_weights_file_name):
# thanks the keras function for loading a model from JSON, this becomes
# very easy to understand and work. Alternative would be to load model
# from binary like cPickle but then model would be obfuscated to users
vqa_model = model_from_json(open(VQA_model_file_name).read())
# vqa_model.summary()
vqa_model.load_model(VQA_weights_file_name)
vqa_model.compile(loss='categorical_crossentropy', optimizer='rmsprop')
return vqa_model`