PixelLib icon indicating copy to clipboard operation
PixelLib copied to clipboard

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

Open fyellow opened this issue 2 years ago • 13 comments

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?

fyellow avatar Apr 25 '22 06:04 fyellow

I am also facing the same ssue

sparshgarg23 avatar Apr 27 '22 05:04 sparshgarg23

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

KorraHaswi avatar May 04 '22 17:05 KorraHaswi

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.

sparshgarg23 avatar May 04 '22 17:05 sparshgarg23

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?.

KorraHaswi avatar May 04 '22 18:05 KorraHaswi

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.

sparshgarg23 avatar May 04 '22 19:05 sparshgarg23

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 avatar May 04 '22 19:05 KorraHaswi

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?

KorraHaswi avatar May 04 '22 23:05 KorraHaswi

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.

sparshgarg23 avatar May 05 '22 04:05 sparshgarg23

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?

Pierre-EtienneM avatar Jun 11 '22 18:06 Pierre-EtienneM

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")

lievenFlux avatar Nov 23 '22 11:11 lievenFlux

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

zarza avatar Nov 26 '22 22:11 zarza

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

zarza avatar Nov 26 '22 22:11 zarza

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.

lievenFlux avatar Dec 01 '22 09:12 lievenFlux