yu4u / age-gender-estimation

Keras implementation of a CNN network for age and gender estimation
MIT License
1.46k stars 502 forks source link

has no attribute 'EfficientNetB3' #127

Open Arash-HR opened 4 years ago

Arash-HR commented 4 years ago

Hi when run demo.py , get this error ;

File "demo.py", line 92, in main
    model = get_model(cfg)
  File "/home/arash/Desktop/age-gender-estimation/src/factory.py", line 8, in get_model
    base_model = getattr(applications, cfg.model.model_name)(
AttributeError: module 'tensorflow.keras.applications' has no attribute 'EfficientNetB3'

I was worked with this repo without any problem before recent commits , but now ... There is someone to help me ?

Bloodrammer commented 4 years ago

Make sure you have the latest tensorflow version installed, which is 2.3.0

Arash-HR commented 4 years ago

@Bloodrammer

I have installed the latest version of Tensorflow

>>> import tensorflow as tf
>>> print(tf.__version__)
2.3.0
yu4u commented 4 years ago

How about this? The different version of Python might be used in running demo.

>>> import tensorflow as tf
>>> print(tf.__version__)
2.3.0
>>> tf.keras.applications.__dict__.keys()
dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__path__', '__file__', '__cached__', '__builtins__', '_sys', 'densenet', 'efficientnet', 'imagenet_utils', 'inception_resnet_v2', 'inception_v3', 'mobilenet', 'mobilenet_v2', 'nasnet', 'resnet', 'resnet50', 'resnet_v2', 'vgg16', 'vgg19', 'xception', 'DenseNet121', 'DenseNet169', 'DenseNet201', 'EfficientNetB0', 'EfficientNetB1', 'EfficientNetB2', 'EfficientNetB3', 'EfficientNetB4', 'EfficientNetB5', 'EfficientNetB6', 'EfficientNetB7', 'InceptionResNetV2', 'InceptionV3', 'MobileNet', 'MobileNetV2', 'NASNetLarge', 'NASNetMobile', 'ResNet101', 'ResNet152', 'ResNet50', 'ResNet101V2', 'ResNet152V2', 'ResNet50V2', 'VGG16', 'VGG19', 'Xception'])
Arash-HR commented 4 years ago

@yu4u

>>> import tensorflow as tf
>>> print(tf.__version__)
2.3.0
>>> tf.keras.applications.__dict__.keys()
dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__path__', '__file__', '__cached__', '__builtins__', '_sys', 'densenet', 'efficientnet', 'imagenet_utils', 'inception_resnet_v2', 'inception_v3', 'mobilenet', 'mobilenet_v2', 'nasnet', 'resnet', 'resnet50', 'resnet_v2', 'vgg16', 'vgg19', 'xception', 'DenseNet121', 'DenseNet169', 'DenseNet201', 'EfficientNetB0', 'EfficientNetB1', 'EfficientNetB2', 'EfficientNetB3', 'EfficientNetB4', 'EfficientNetB5', 'EfficientNetB6', 'EfficientNetB7', 'InceptionResNetV2', 'InceptionV3', 'MobileNet', 'MobileNetV2', 'NASNetLarge', 'NASNetMobile', 'ResNet101', 'ResNet152', 'ResNet50', 'ResNet101V2', 'ResNet152V2', 'ResNet50V2', 'VGG16', 'VGG19', 'Xception'])
yu4u commented 4 years ago

It's strange. EfficientNetB3 does exist.

gmt710 commented 3 years ago

@yu4u , Hello, EfficientNetB3 ' s input size is 300 300, but the age and gender estimate model is 224 224. How can we get the EfficientNetB3 pretrained model?

image

yu4u commented 3 years ago

https://github.com/yu4u/age-gender-estimation/blob/master/src/factory.py#L7-L17

gmt710 commented 3 years ago

But another error will occur.

ValueError: You are trying to load a weight file containing 211 layers into a model with 210 layers.
yu4u commented 3 years ago

How can I reproduce the error?

gmt710 commented 3 years ago

My enviroment:

cuda9.0
tensorflow == v1.12.0
keras == 2.2.4

I add EfficientNet to keras.applications. I run demo.py and get the error.

ValueError: You are trying to load a weight file containing 211 layers into a model with 210 layers.
yu4u commented 3 years ago

Please use tensorflow>=2.3.0

gmt710 commented 3 years ago

Sorry, My cuda version doesn‘t support it. It's not easy for me to change the servers' env.

gmt710 commented 3 years ago

cuda10.1 tensorflow-v2.3.0 is ok.