Program exit with error: 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).
import tensorflow as tf
from pixellib.instance import instance_segmentation
gpus = tf.config.experimental.list_physical_devices("GPU")
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
def detect():
segment = instance_segmentation()
segment.load_model("C:\\Users\\User\\PycharmProjects\\FaceDetectionSchoolProject\\mask_rcnn_balloon.h5")
target_classes = segment.select_target_classes(person=True)
result = segment.segmentImage(
image_path="InputData\\bus.jpg",
show_bboxes=True,
segment_target_classes=target_classes,
output_image_name="obus.jpg"
)
persons = len(result[0]["sources"])
print(persons)
def main():
detect()
I try to using tensorflow-gpu 2.8.0 with pixellib 0.7.1 and I get this error:
WARNING:tensorflow:From C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\venv\lib\site-packages\tensorflow\python\util\deprecation.py:616: calling map_fn_v2 (from tensorflow.python.ops.map_fn) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Use fn_output_signature instead
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\main.py", line 31, in <module>
main()
File "C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\main.py", line 27, in main
detect()
File "C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\main.py", line 11, in detect
segment.load_model("C:\\Users\\User\\PycharmProjects\\FaceDetectionSchoolProject\\mask_rcnn_balloon.h5")
File "C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\venv\lib\site-packages\pixellib\instance\__init__.py", line 65, in load_model
self.model.load_weights(model_path, by_name= True)
File "C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\venv\lib\site-packages\pixellib\instance\mask_rcnn.py", line 2110, in load_weights
hdf5_format.load_weights_from_hdf5_group_by_name(f, layers)
File "C:\Users\User\PycharmProjects\FaceDetectionSchoolProject\venv\lib\site-packages\tensorflow\python\keras\saving\hdf5_format.py", line 795, in load_weights_from_hdf5_group_by_name
str(weight_values[i].shape) + '.')
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).