OniroAI / Semantic-segmentation-with-MobileNetV3

TensorFlow (Keras) implementation of MobileNetV3 and its segmentation head
GNU General Public License v3.0
61 stars 14 forks source link

Can't load pretrained model #7

Closed wshuang808 closed 3 years ago

wshuang808 commented 3 years ago

Hi, thanks for the project. It's really interesting to play and learn from it. However I got ValueError: Shapes (1, 1, 24, 2) and (1, 1, 24, 1) are incompatible when trying to load the pretrained model. Seems like it has some problem while loading weights from the model. I also noticed that you mentioned the pretrained model was trained with TF2.0. Could that be the cause of this issue? I am with TF2.3 btw.

wshuang808 commented 3 years ago

I managed to figure out the reason. The n_class should be 1, however for some reason I changed it to 2.

voeykovroman commented 3 years ago

Was going to take a look during the weekend, but you've already solved it! Thanks! Yes, the thing was to pass the correct parameters to the model constructor to load the pretrained models (which were built with the parameters you can find in the training notebook)