Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The input must have 3 channels, I need 1 channel #147

Open
MohannadEhabBarakat opened this issue Aug 29, 2021 · 2 comments
Open

The input must have 3 channels, I need 1 channel #147

MohannadEhabBarakat opened this issue Aug 29, 2021 · 2 comments

Comments

@MohannadEhabBarakat
Copy link

When running following code
base_model = efn.EfficientNetB0(include_top=False, weights='imagenet', input_shape=(256,256,1))
I get
Traceback (most recent call last):
File "models/discriminator.py", line 40, in
model = discriminator((256,256,1))
File "models/discriminator.py", line 19, in discriminator
base_model.input = layers.Input(input_shape)
File "/home/mbarakat/anaconda3/envs/tf1/lib/python3.6/site-packages/keras/engine/network.py", line 323, in setattr
super(Network, self).setattr(name, value)
File "/home/mbarakat/anaconda3/envs/tf1/lib/python3.6/site-packages/keras/engine/base_layer.py", line 1245, in setattr
super(Layer, self).setattr(name, value)
AttributeError: can't set attribute
(tf1) mbarakat@ml-server2:~/gan$ python models/discriminator.py
Using TensorFlow backend.
Traceback (most recent call last):
File "models/discriminator.py", line 40, in
model = discriminator((256,256,1))
File "models/discriminator.py", line 11, in discriminator
base_model = efn.EfficientNetB0(include_top=False, weights='imagenet', input_shape=input_shape)
File "/home/mbarakat/anaconda3/envs/tf1/lib/python3.6/site-packages/efficientnet/init.py", line 44, in wrapper
return func(*args, **kwargs)
File "/home/mbarakat/anaconda3/envs/tf1/lib/python3.6/site-packages/efficientnet/model.py", line 477, in EfficientNetB0
**kwargs
File "/home/mbarakat/anaconda3/envs/tf1/lib/python3.6/site-packages/efficientnet/model.py", line 326, in EfficientNet
weights=weights)
File "/home/mbarakat/anaconda3/envs/tf1/lib/python3.6/site-packages/keras_applications/imagenet_utils.py", line 316, in _obtain_input_shape
'input_shape=' + str(input_shape) + '')
ValueError: The input must have 3 channels; got input_shape=(256, 256, 1)

@innat
Copy link

innat commented Nov 21, 2021

You can add a convolutional layer with feature maps 3 with pad size 3 (same) to match with the imagenet weights.

@atamazian
Copy link

This issue is not related to the package itself, so I suggest to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants