PixelLib icon indicating copy to clipboard operation
PixelLib copied to clipboard

Pixel Lib Value Error

Open firaki12345-cmd opened this issue 3 years ago • 5 comments

HI, everyone

SO i am trying to do instance segmentation with PIxel lib ,but get the following Value Error

My Code:

import pixellib
from pixellib.tune_bg import alter_bg
from pixellib.instance import instance_segmentation  
from matplotlib import pyplot as plt
from PIL import Image

segmentation_model = instance_segmentation()

segmentation_model.load_model("./mask_rcnn_balloon.h5")

target_classes = segmentation_model.select_target_classes(people == "True")

My Error:

ValueError                                Traceback (most recent call last)
/tmp/ipykernel_147/3813335621.py in <module>
      1 segmentation_model = instance_segmentation()
      2 
----> 3 segmentation_model.load_model("./mask_rcnn_balloon.h5")
      4 
      5 target_classes = segmentation_model.select_target_classes(people == "True")

/opt/conda/lib/python3.7/site-packages/pixellib/instance/__init__.py in load_model(self, model_path, confidence)
     63         self.model = MaskRCNN(mode = "inference", model_dir = self.model_dir, config = coco_config)
     64 
---> 65         self.model.load_weights(model_path, by_name= True)
     66 
     67 

/opt/conda/lib/python3.7/site-packages/pixellib/instance/mask_rcnn.py in load_weights(self, filepath, by_name, exclude)
   2108 
   2109             if by_name:
-> 2110                 hdf5_format.load_weights_from_hdf5_group_by_name(f, layers)
   2111             else:
   2112                 hdf5_format.load_weights_from_hdf5_group(f, layers)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/saving/hdf5_format.py in load_weights_from_hdf5_group_by_name(f, layers, skip_mismatch)
    793                                symbolic_weights[i])) +
    794                            ', but the saved weight has shape ' +
--> 795                            str(weight_values[i].shape) + '.')
    796 
    797         else:

ValueError: 

Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 324) dtype=float32> has shape (1024, 324), but the saved weight has shape (1024, 8).

There is no option for excludng "mrcnn_bbox_fc". Please Help :(

EDIT: OK, so it WORKS with 2.0 but not 2.1 baloon.h5 Model (Why is that ? )

firaki12345-cmd avatar Oct 25 '21 12:10 firaki12345-cmd

is there any updates on this? i'm having the same problem

alcanunsal avatar Nov 01 '21 08:11 alcanunsal

is there any updates on this? i'm having the same problem

hi, i have also found another great git-hub project to remove background from images, and have been using it since

https://github.com/OPHoperHPO/image-background-remove-tool

firaki12345-cmd avatar Nov 02 '21 12:11 firaki12345-cmd

thanks @firaki12345-cmd I'll take a look at it

alcanunsal avatar Nov 12 '21 08:11 alcanunsal

im having the same error , i cannot find any way to exclude layers on pixellib

Tubhalooter avatar Nov 12 '21 11:11 Tubhalooter

same error when running on video

PrakharPrashantSingh avatar Apr 26 '22 09:04 PrakharPrashantSingh