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

ValueError: The channel dimension of the inputs should be defined. Found None. #50

Closed
GerrieWell opened this issue Jan 22, 2018 · 8 comments

Comments

@GerrieWell
Copy link

GerrieWell commented Jan 22, 2018

Traceback (most recent call last):
  File "./demo_image.py", line 247, in <module>
    model = get_testing_model()
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 184, in get_testing_model
    stage0_out = vgg_block(img_normalized, None)
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 29, in vgg_block
    x = conv(x, 64, 3, "conv1_1", (weight_decay, 0))
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 20, in conv
    bias_initializer=constant(0.0))(x)
  File "/home/wuyong/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/engine/topology.py", line 528, in __call__
    self.build(input_shapes[0])
  File "/home/wuyong/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/layers/convolutional.py", line 125, in build
    raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found `None`.

Seem like something wrong with img_input_shape. So I chance 177 line of model.py to this:

img_input_shape = (None, None, 3) ==>
   img_input_shape = (674, 712, 3)

Then new error occur:

Traceback (most recent call last):
  File "./demo_image.py", line 247, in <module>
    model = get_testing_model()
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 184, in get_testing_model
    stage0_out = vgg_block(img_normalized, None)
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 40, in vgg_block
    x = pooling(x, 2, 2, "pool2_1")
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 24, in pooling
    x = MaxPooling2D((ks, ks), strides=(st, st), name=name)(x)
  raise ValueError(err.message)
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'pool2_1/MaxPool' (op: 'MaxPool') with input shapes: [?,356,1,128].

What's wrong with that?
What shape img_input_shape should be ?

@anatolix
Copy link

anatolix commented Jan 22, 2018

674/8 = 84.25
should be multiplicity of stride_size(ie int(N)*stride), stride is currently 8.
Pad it with few extra pixels with color (128,128,128)

@GerrieWell
Copy link
Author

@anatolix Thanks for your answer.
Do u mean use (128,128,128) as the value of img_input_shape? I'm not familiar with pose estimation. And I use the last commit(e05cb7). I just wanna reproduced the demo result( python demo_image.py --image ./sample_images/ski.jpg ). What other arguments do I need to modify to implement it?
Thank you very much in advance.

@GerrieWell
Copy link
Author

I got this error message with using (128,128,128)

(tensorflow) wuyong@xy-desktop:~/Share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation$ python demo_image.py --image ./sample_images/ski.jpg
Using TensorFlow backend.
start processing...
Traceback (most recent call last):
  File "demo_image.py", line 247, in <module>
    model = get_testing_model()
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 192, in get_testing_model
    x = Concatenate()([stage1_branch1_out, stage1_branch2_out, stage0_out])
  File "/home/wuyong/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/engine/topology.py", line 530, in __call__
    self.build(input_shapes)
  File "/home/wuyong/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/layers/merge.py", line 160, in build
    'Got inputs shapes: %s' % (input_shape))
ValueError: `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 38, 16, 16), (None, 19, 16, 16), (None, 128, 16, 16)] 

@GerrieWell
Copy link
Author

I try assign Concatenate with axis from 0~3. But none of them make it work.

@anatolix
Copy link

Do u mean use (128,128,128) as the value of img_input_shape?

no.
I mean what input image could be 8x8 or 16x8 or 80x80 but not 81xSomething.
if you image is 81x80 just make it 88x80 by padding 7 extra pixels.
Pixels should be gray color = (128,128,128)

btw you have working code in notebook and demo.py just look there.

line: img_input_shape = (None, None, 3) in model shouldn't be touched at all - None means "autodetect"
network is fully convolutional i.e could take any shapes with 8 pixels step

@GerrieWell
Copy link
Author

GerrieWell commented Jan 24, 2018

So what's wrong with the code? I really have no idea. I try to reset hard to last commit. And it still output like that:

python demo_image.py --image ./sample_images/ski.jpg
Using TensorFlow backend.
start processing...
Traceback (most recent call last):
  File "demo_image.py", line 247, in <module>
    model = get_testing_model()
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 184, in get_testing_model
    stage0_out = vgg_block(img_normalized, None)
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 29, in vgg_block
    x = conv(x, 64, 3, "conv1_1", (weight_decay, 0))
  File "/home/xy/share/reidPrj/keras_Realtime_Multi-Person_Pose_Estimation/model.py", line 20, in conv
    bias_initializer=constant(0.0))(x)
  File "/home/wuyong/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/engine/topology.py", line 528, in __call__
    self.build(input_shapes[0])
  File "/home/wuyong/anaconda3/envs/tensorflow/lib/python3.5/site-packages/keras/layers/convolutional.py", line 125, in build
    raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found `None`.

I don't think there are something wrong with my tensorflow cause the tensorflow demo run perfectly(python mnist_deep.py ), and so other projects are. BTW, the message showed it's using gpu GTX1080 when I tried other project.
Do u have any suggestions?

@anatolix
Copy link

In this case it could be some keras compatibility problem, can't reproduce anything like this

@sravankumar-challa
Copy link

sravankumar-challa commented Feb 26, 2019

Just update keras version to 2.1.2
pip install keras==2.1.2

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