Error in transfer learning

While fitting my model i am getting this error that
No. Of channel inherent in the image must be 1,3,4 found 2.
Pls help me with this error.
I don’t understand what this error is about.
Until my model.fit my every cell is correct and runs without any error.
Pls explain and suggest any solution.

Thank you.

Number of channels, usually 3, refers to red, green, blue.

What’s IMG_SHAPE i.e. the input_shape to MobileNetV2? It’s should be (160, 160, 3)

Yes i tried input shape of 160,160,3
But still there is error

@paulinpaloalto might be able to look at your lab with your id.

Sorry, only the course staff has the magic power to look at someone else’s notebook. The mentors are just fellow student volunteers. We can’t do that.

It looks like you must be running locally, since there is no /usr/local/lib/python3.7 in the notebook environment. If you are running locally, you are probably using different versions of TF and lots of other things. There is no guarantee that the notebook code will run with some random version of the support packages it depends on. We do not have “official” instructions for how to do this, but here’s a thread from a fellow student with lots of useful instructions. But as you’ll see from a quick scan of that thread, these are deep waters. Be warned: There Be Dragons! :scream_cat:

Thanks for your instructions.
But im running this on “google colab”.

@user344 Could you please message (not public on the forum but as a message) your file as an attachment or share your file via colab?

That’s useful to know. I have not tried that. There is no guarantee that it works for the same “versionitis” reasons. The first question would be whether you can use TF 2.3.0 in the context of Colab, as opposed to whatever the latest version is that they are running. Then you’ve got to deal with differences in all the other packages.

If you figure out how to get this to work, it would be a public service if you could let us know your recipe. Thanks!

Thanks for your help.
But do you think because of all this I am getting that error.

We have seen errors before when people try to run on TF 2.6 instead of 2.3. I don’t remember if they were exactly the same as the error you show. Try running the same code on the course website. If that works, then that’s a pretty good indication that it’s an environment problem.

Ok, thanks for your help and guidance.
I will definitely try it out and will let you know.

@user344 #fit the model
r = model.fit_generator(train_set,validation_data=test_set,epochs=4,steps_per_epoch=len(train_set),validation_steps=len(test_set))

try this code and run it if you face any further error they inform .

All the best

This error usually pops up in tensorflow decode_bmp(…) function. I had workaround this replacing the input data format in a different project, but as others have pointed out its mostly due to version mismatch in packages.

1 Like

Based on google search results, decode_bmp seems to be a problem. @gopiramena If it’s not too much trouble, could you file a ticket? Thanks.