machrisaa / tensorflow-vgg

VGG19 and VGG16 on Tensorflow
2.21k stars 1.08k forks source link

KeyError Message after loading the npy file #40

Closed wenouyang closed 6 years ago

wenouyang commented 7 years ago

Hi, Thank you for sharing the code.

I have been trying to running the test_vgg16.py, and it gives the error message as follows. Would you like to let me know the possible reason for this?

npy file loaded build model started Traceback (most recent call last): File "test_vgg16.py", line 23, in <module> vgg.build(images) File "/home/DL-Phase3/tensorflow-vgg-master/vgg16.py", line 47, in build self.conv1_1 = self.conv_layer(bgr, "conv1_1") File "/home/DL-Phase3/tensorflow-vgg-master/vgg16.py", line 92, in conv_layer filt = self.get_conv_filter(name) File "/home/DL-Phase3/tensorflow-vgg-master/vgg16.py", line 120, in get_conv_filter return tf.constant(self.data_dict[name][0], name="filter") KeyError: 0

mcimpoi commented 7 years ago

Did the model load properly? L20 (vgg16.py) self.data_dict = np.load(vgg16_npy_path, encoding='latin1').item() try print the keys and the shapes of the entries in the data dict: Something like this:

        for key in self.data_dict:
            print(key, self.data_dict[key][0].shape, self.data_dict[key][1].shape)

what version of python are you using?

aditipanda commented 6 years ago

@mcimpoi I tried running the code snippet you provided. It still gives a key error. Details:

File "F:\3rd_Sem\15%\For Validation\model2_new_PerceptLoss_1.py", line 74, in build_model print(key, self.data_dict[key][0].shape, self.data_dict[key][1].shape)

KeyError: 0