Closed oxydron closed 7 years ago
Thanks for pointing out. I think Keras API is changed after the last time I updated the project. The code sample in new README file should work now.
Tried again and got this:
Traceback (most recent call last):
File "fine_tuning.py", line 16, in <module>
x = Flatten(name='flatten')(last_layer)
File "/home/bh/anaconda3/envs/keras2/lib/python3.6/site-packages/keras/engine/topology.py", line 559, in __call__
output_shape = self.compute_output_shape(input_shape)
File "/home/bh/anaconda3/envs/keras2/lib/python3.6/site-packages/keras/layers/core.py", line 488, in compute_output_shape
'(got ' + str(input_shape[1:]) + '. '
ValueError: The shape of the input to "Flatten" is not fully defined (got (None, None, 512). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.
Tried to get the model summary and got this, with lots of None
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, None, None, 3) 0
_________________________________________________________________
conv1_1 (Conv2D) (None, None, None, 64) 1792
_________________________________________________________________
conv1_2 (Conv2D) (None, None, None, 64) 36928
_________________________________________________________________
pool1 (MaxPooling2D) (None, None, None, 64) 0
_________________________________________________________________
conv2_1 (Conv2D) (None, None, None, 128) 73856
_________________________________________________________________
conv2_2 (Conv2D) (None, None, None, 128) 147584
_________________________________________________________________
pool2 (MaxPooling2D) (None, None, None, 128) 0
_________________________________________________________________
conv3_1 (Conv2D) (None, None, None, 256) 295168
_________________________________________________________________
conv3_2 (Conv2D) (None, None, None, 256) 590080
_________________________________________________________________
conv3_3 (Conv2D) (None, None, None, 256) 590080
_________________________________________________________________
pool3 (MaxPooling2D) (None, None, None, 256) 0
_________________________________________________________________
conv4_1 (Conv2D) (None, None, None, 512) 1180160
_________________________________________________________________
conv4_2 (Conv2D) (None, None, None, 512) 2359808
_________________________________________________________________
conv4_3 (Conv2D) (None, None, None, 512) 2359808
_________________________________________________________________
pool4 (MaxPooling2D) (None, None, None, 512) 0
_________________________________________________________________
conv5_1 (Conv2D) (None, None, None, 512) 2359808
_________________________________________________________________
conv5_2 (Conv2D) (None, None, None, 512) 2359808
_________________________________________________________________
conv5_3 (Conv2D) (None, None, None, 512) 2359808
_________________________________________________________________
pool5 (MaxPooling2D) (None, None, None, 512) 0
=================================================================
Total params: 14,714,688.0
Trainable params: 0.0
Non-trainable params: 14,714,688.0
_________________________________________________________________
I need to know the none values on the pool5 = (None, None, None, 512)
According to the Keras source codes, if the include_top is set to False
, then input_shape should be (224, 224, 3)
or (3,224,224)
depending your backend. We should initialise the model as follows:
vgg_model = VGGFace(include_top=False, input_shape=(224, 224, 3)) #TF backend
I will also update the README file again.
Maybe you should add those parameters inside the code and take off the parameter, no?
vgg_model = VGGFace(include_top=False) #TF backend
inside VGGFace():
...
input_shape=(224, 224, 3)
...
Worked with your solution :+1: Thank you very much :)
Tried to run the example on the README of this repo and got this:
Conda enviroment (irrelevant packages excluded for clarity):