[instance segmentation]pixellib fails to remove _background_ label in labelme on custom dataset

Viewed 42

I learn pixellib to do instance segmentation at pixellib.

I used labelme to mark 4 categories of objects.According to the document of labelme, I used the label _background_ to mark the parts that do not belong to the object.

The 4 categories of objects are plastic bag,drink bottle,banana,apple.

When I use this code to train my own dataset:

from pixellib.custom_train import instance_custom_training
train_maskrcnn = instance_custom_training()
train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes=4, batch_size=4, class_names= ["_background_","apple","banana","drinkBottle","plasticBag"])
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
train_maskrcnn.load_dataset(r'myData')
train_maskrcnn.train_model(num_epochs = 300, augmentation=True,  path_trained_models = r"D:/pythonProjects/model") 

I find the categories in test.json and train.json is:

"categories": [
        {
            "supercategory": "apple",
            "id": 1,
            "name": "apple"
        },
        {
            "supercategory": "_background_",
            "id": 2,
            "name": "_background_"
        },
        {
            "supercategory": "banana",
            "id": 3,
            "name": "banana"
        },
        {
            "supercategory": "plasticBag",
            "id": 4,
            "name": "plasticBag"
        },
        {
            "supercategory": "drinkBottle",
            "id": 5,
            "name": "drinkBottle"
        }
    ]

And the error message is:

Traceback (most recent call last):
  File "D:/pythonProjects/test_mask.py", line 6, in <module>
    train_maskrcnn.train_model(num_epochs = 300, augmentation=True,  path_trained_models = r"D:/pythonProjects/model") 
  File "D:\Anaconda38\lib\site-packages\pixellib\custom_train\__init__.py", line 124, in train_model
    self.model.train(self.dataset_train, self.dataset_test,models = path_trained_models, augmentation = augmentation, 
  File "D:\Anaconda38\lib\site-packages\pixellib\instance\mask_rcnn.py", line 2307, in train
    self.keras_model.fit(
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_v1.py", line 776, in fit
    return func.fit(
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_generator_v1.py", line 570, in fit
    return fit_generator(
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_generator_v1.py", line 252, in model_iteration
    batch_outs = batch_function(*batch_data)
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_v1.py", line 1048, in train_on_batch
    x, y, sample_weights = self._standardize_user_data(
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_v1.py", line 2323, in _standardize_user_data
    return self._standardize_tensors(
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_v1.py", line 2351, in _standardize_tensors
    x = training_utils_v1.standardize_input_data(
  File "D:\Anaconda38\lib\site-packages\keras\engine\training_utils_v1.py", line 642, in standardize_input_data
    raise ValueError('Error when checking ' + exception_prefix +
ValueError: Error when checking input: expected input_image_meta to have shape (17,) but got array with shape (18,)

I know that _background_ is a special category and should not be trained as a category, and _background_ should not appear under the node categories in test.json and train.json, so how should I modify my code?

0 Answers
Related