ayoolaolafenwa / PixelLib

Visit PixelLib's official documentation https://pixellib.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

fyellow opened this issue · 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?

I am also facing the same ssue

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

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.

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

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.

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?

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?

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.

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?

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

commented

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

commented

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

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.