ml5js / ml5-library

Friendly machine learning for the web! 🤖
https://ml5js.org
Other
6.45k stars 906 forks source link

Uncaught Error: error in conv2dDerInput: depth of input (64) must match input depth for filter32 #281

Open calvinlcchen opened 5 years ago

calvinlcchen commented 5 years ago

Nature of issue?


Details about the Bug:

To improve the inference performance and support larger input image for style transfer, I try to reduce filter num to 1/4 ,for each layer when training model. ex. initial filter_num to 16 from 32 for 1st conv2d_layer. Convert to variables, it can't be inferenced sucessfully. it show the error as subject.

Web browser and version: (e.g. Firefox version 65, Chrome version 71.0)

Chrome version 72.0

Operating System: (e.g. MacOS, Windows, Ubuntu)

Windows 10


New feature details:

support lower filter size for style transfer

bomanimc commented 3 years ago

Hi @calvinlcchen. Do you mind sharing some example code that illustrates this issue? Would be happy to try to get a better understanding of your question/suggestion!

calvinlcchen commented 3 years ago

Hi Bomani, I had wrote down the adjustment in my project in github, you can refer to https://github.com/acerwebai/VangoghCrazyWorld-Web

Regards, Calvin

Bomani Oseni McClendon notifications@github.com 於 2020年9月17日 週四 上午5:20寫道:

Hi @calvinlcchen https://github.com/calvinlcchen. Do you mind sharing some example code that illustrates this issue? Would be happy to try to get a better understanding of your question/suggestion!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ml5js/ml5-library/issues/281#issuecomment-693671727, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFIFPHXIAELY7QWQOSLLFLSGET2LANCNFSM4GXV4V4Q .

-- Calvin Chen

lindapaiste commented 2 years ago

Hi @calvinlcchen

This is an old issue but it's a very interesting feature request as I know that the StyleTransfer model is very memory-intensive.

There will definitely be issues if the numbers that are in the code don't match up with the shape of your weights variables. Your situation is that you have models which are correctly trained to use a lesser number of inputs, but ml5 still expects the higher number, correct?

This seems like it is something that should be fixable on our end. The manifest.json contains enough information for us to work backwards and derive the correct constants.

I introduced a utility that can infer the IMAGE_SHAPE for some other models in PR #1387. It will need to be slightly different here because the StyleTransfer is just a manifest and raw weights rather than a complete TFJS model. But I will have fun playing with all of these great models that you've trained!