ayoolaolafenwa / PixelLib

Visit PixelLib's official documentation https://pixellib.readthedocs.io/en/latest/
MIT License
1.05k stars 264 forks source link

You are trying to load a weight file containing 293 layers into a model with 147 layers. #138

Open fyellow opened 2 years ago

fyellow commented 2 years ago

While segment_image = semantic_segmentation() segment_image.load_pascalvoc_model("deeplabv3_xception_tf_dim_ordering_tf_kernels.h5") The above error keeps coming up. Any solutions?

sparshgarg23 commented 2 years ago

I am also facing the same ssue

KorraHaswi commented 2 years ago

same issue i am facing. looks like the model is not correct. she needs to tell us what is the correct model

sparshgarg23 commented 2 years ago

you can refer to https://github.com/spmallick/learnopencv/tree/master/app-seperation-semseg this actually worked for me. It offers the same applications like the author of this repo proposes like background changing,background blurring etc.

KorraHaswi commented 2 years ago

you can refer to https://github.com/spmallick/learnopencv/tree/master/app-seperation-semseg this actually worked for me. It offers the same applications like the author of this repo proposes like background changing,background blurring etc.

Thanks for the information touchgarg23. were you able to resolve the original issue?.

sparshgarg23 commented 2 years ago

no plus the model needed to be changed so as to make it compatible with modern tensorflow versions. Based on the fact that model needed changes ,and the fact that the weight file wasn't loading decided to use the above link.It's in pytorch which is more stable compared to tensorflow.

KorraHaswi commented 2 years ago

no plus the model needed to be changed so as to make it compatible with modern tensorflow versions. Based on the fact that model needed changes ,and the fact that the weight file wasn't loading decided to use the above link.It's in pytorch which is more stable compared to tensorflow.

thanks you so much. I am actually extract the foreground isntead of changing the backround. I have dataset that contains one human in a lab setting. the idea is to find out the mask that change background script is using to change the BG. do u know how i can get this mask?

KorraHaswi commented 2 years ago

no plus the model needed to be changed so as to make it compatible with modern tensorflow versions. Based on the fact that model needed changes ,and the fact that the weight file wasn't loading decided to use the above link.It's in pytorch which is more stable compared to tensorflow.

I used the link you shared. the output image is black. any idea why?

sparshgarg23 commented 2 years ago

Refer to this https://stackoverflow.com/questions/54165365/opencv2-imwrite-is-writing-a-black-image Are you trying to write the image using cv2.imwrite? use this

rgb1= cv2.convertScaleAbs(rgb, alpha=(255.0))

and the convert color of that image from RGB to BGR for display purposes.

Pierre-EtienneM commented 2 years ago

I still have this problem and looking at the PixelLib version 0.1.0 (the first one) it still had this problem so did it never work or the deeplabv3_xception65_ade20k.h5 file layer changed and is not working anymore? If so just publishing the older version could fix it?

lievenFlux commented 1 year ago

i'm having the same error running this example below on a mac m1. on a windows computer i don't see this error.

import pixellib from pixellib.semantic
import semantic_segmentation
segment_image = semantic_segmentation()
segment_image.load_ade20k_model("deeplabv3_xception65_ade20k.h5")
segment_image.segmentAsAde20k("input.jpg", output_image_name = "output.jpg")

zarza commented 1 year ago

Same error right here... Any solution or workaround?

zarza commented 1 year ago

ValueError: You are trying to load a weight file containing 293 layers into a model with 147 layers

lievenFlux commented 1 year ago

I got it working by changing some imports in pixellib/semantic/deeplab.py.

You can substitute all imports tensorflow.python.keras with tensorflow.keras exept for from tensorflow.python.keras.utils.layer_utils import get_source_inputs.