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