rcmalli / keras-vggface

VGGFace implementation with Keras Framework
MIT License
928 stars 417 forks source link

I am trying to use VGGFace with resnet50, but with smaller image dimensions, I was wondering how can I do this without re-training the model from scratch... #52

Closed TheStoneMX closed 5 years ago

TheStoneMX commented 5 years ago

Please run this code and share your library versions

import tensorflow as tf
import keras
import keras_vggface

print(tf.__version__)
print(keras.__version__)
print(keras_vggface.__version__)

Using TensorFlow backend.
1.13.1
2.2.4
0.5

**Bug reports:**

Please replace this line with a brief summary of your issue AND if reporting a build issue include the link from:

**Code Sample:**

I am trying to use VGGFace with resnet50, but with smaller image dimensions, I was wondering how can I do this without re-training the model from scratch...


base_model = VGGFace(model='resnet50', include_top=False, inputshape=(96, 96, 3))

**Error**
Negative dimension size caused by subtracting 7 from 3 for 'vggface_resnet50/avg_pool/AvgPool' (op: 'AvgPool') with input shapes: [?,3,3,2048].
rcmalli commented 5 years ago

The input size was not supported as low as 96x96. Now it should be fixed.

werlang commented 5 years ago

Same error ocurred to me when fine tuning:

VGGFace(model='resnet50', include_top=False, input_shape=(112, 112, 3))

ERROR: ValueError: Negative dimension size caused by subtracting 7 from 4 for 'avg_pool_2/AvgPool' (op: 'AvgPool') with input shapes: [?,4,4,2048].

tf version 1.14.0 keras version 2.2.0 vggface version 0.6

prathmeshrmadhu commented 4 years ago

The input size was not supported as low as 96x96. Now it should be fixed.

Hello, @rcmalli I am also getting the same error as werlang. Could you please comment, if there is something that we could be possibly missing?

sherlockchou86 commented 4 years ago

If you use smaller input shape, maybe we need decrease the number of CNN layers in networks accordingly. Because Conv2D or Average/MaxPooling layers will reduce the dims of features map layer by layer, if the input shape is too small, there is no space/data for those layers to operate.

annezao commented 2 years ago

Any thoughts about it?

Same error ocurred to me when fine tuning:

VGGFace(model='resnet50', include_top=False, input_shape=(112, 112, 3))

ERROR: ValueError: Negative dimension size caused by subtracting 7 from 4 for 'avg_pool_2/AvgPool' (op: 'AvgPool') with input shapes: [?,4,4,2048].

tf version 1.14.0 keras version 2.2.0 vggface version 0.6