You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11) and generator_output = next(output_generator) StopIteration
#3043
Open
ZaidArman opened this issue
Jul 3, 2024
· 0 comments
I am trying to train this model for 3 days with the dataset I have. I am using TF 1.3, keras2.0.8, python 3.4 (the recommended versions)
My dataset consists of plants (species) and I have total 8 + 1 (classes + background). I've annotated the images of the plants using VGG Image annotator and then download the json file individually for training and testing. Am I doing something wrong with the annotation, perhaps? You can check the .json file here.
I am facing 2 error:
1:-
`
Starting at epoch 0. LR=0.001
Checkpoint Path: /Users/apple/Documents/Custom_MaskRCNN/logs/object20240703T2142/mask_rcnn_object_{epoch:04d}.h5
Selecting layers to train
fpn_c5p5 (Conv2D)
fpn_c4p4 (Conv2D)
fpn_c3p3 (Conv2D)
fpn_c2p2 (Conv2D)
fpn_p5 (Conv2D)
fpn_p2 (Conv2D)
fpn_p3 (Conv2D)
fpn_p4 (Conv2D)
In model: rpn_model
rpn_conv_shared (Conv2D)
rpn_class_raw (Conv2D)
rpn_bbox_pred (Conv2D)
mrcnn_mask_conv1 (TimeDistributed)
mrcnn_mask_bn1 (TimeDistributed)
mrcnn_mask_conv2 (TimeDistributed)
mrcnn_mask_bn2 (TimeDistributed)
mrcnn_class_conv1 (TimeDistributed)
mrcnn_class_bn1 (TimeDistributed)
mrcnn_mask_conv3 (TimeDistributed)
mrcnn_mask_bn3 (TimeDistributed)
mrcnn_class_conv2 (TimeDistributed)
mrcnn_class_bn2 (TimeDistributed)
mrcnn_mask_conv4 (TimeDistributed)
mrcnn_mask_bn4 (TimeDistributed)
mrcnn_bbox_fc (TimeDistributed)
mrcnn_mask_deconv (TimeDistributed)
mrcnn_class_logits (TimeDistributed)
mrcnn_mask (TimeDistributed)
Epoch 1/2
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11) **2 error:-** Traceback (most recent call last):
File "custom.py", line 514, in
train(model)
File "custom.py", line 345, in train
augmentation=augmentation)
File "/Users/apple/Documents/Custom_MaskRCNN/mrcnn/model.py", line 2294, in train
use_multiprocessing=True,
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/engine/training.py", line 2064, in fit_generator
use_multiprocessing=use_multiprocessing)
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/engine/training.py", line 2160, in evaluate_generator
generator_output = next(output_generator)
StopIteration`
and here is my custom code My Code:
`
import os
import sys
import json
import datetime
import numpy as np
import skimage.draw
import imgaug
import warnings
warnings.filterwarnings("ignore")
Root directory of the project
ROOT_DIR = os.path.abspath("../../")
Import Mask RCNN
sys.path.append(ROOT_DIR) # To find local version of the library
from mrcnn.config import Config
from mrcnn import model as modellib, utils
Hi,
I am trying to train this model for 3 days with the dataset I have. I am using TF 1.3, keras2.0.8, python 3.4 (the recommended versions)
My dataset consists of plants (species) and I have total 8 + 1 (classes + background). I've annotated the images of the plants using VGG Image annotator and then download the json file individually for training and testing. Am I doing something wrong with the annotation, perhaps? You can check the .json file here.
I am facing 2 error:
1:-
`
Starting at epoch 0. LR=0.001
Checkpoint Path: /Users/apple/Documents/Custom_MaskRCNN/logs/object20240703T2142/mask_rcnn_object_{epoch:04d}.h5
Selecting layers to train
fpn_c5p5 (Conv2D)
fpn_c4p4 (Conv2D)
fpn_c3p3 (Conv2D)
fpn_c2p2 (Conv2D)
fpn_p5 (Conv2D)
fpn_p2 (Conv2D)
fpn_p3 (Conv2D)
fpn_p4 (Conv2D)
In model: rpn_model
rpn_conv_shared (Conv2D)
rpn_class_raw (Conv2D)
rpn_bbox_pred (Conv2D)
mrcnn_mask_conv1 (TimeDistributed)
mrcnn_mask_bn1 (TimeDistributed)
mrcnn_mask_conv2 (TimeDistributed)
mrcnn_mask_bn2 (TimeDistributed)
mrcnn_class_conv1 (TimeDistributed)
mrcnn_class_bn1 (TimeDistributed)
mrcnn_mask_conv3 (TimeDistributed)
mrcnn_mask_bn3 (TimeDistributed)
mrcnn_class_conv2 (TimeDistributed)
mrcnn_class_bn2 (TimeDistributed)
mrcnn_mask_conv4 (TimeDistributed)
mrcnn_mask_bn4 (TimeDistributed)
mrcnn_bbox_fc (TimeDistributed)
mrcnn_mask_deconv (TimeDistributed)
mrcnn_class_logits (TimeDistributed)
mrcnn_mask (TimeDistributed)
Epoch 1/2
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
ERROR:root:Error in data_generator: Mismatch between number of class IDs (10) and number of masks (11)
**2 error:-**
Traceback (most recent call last):File "custom.py", line 514, in
train(model)
File "custom.py", line 345, in train
augmentation=augmentation)
File "/Users/apple/Documents/Custom_MaskRCNN/mrcnn/model.py", line 2294, in train
use_multiprocessing=True,
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/engine/training.py", line 2064, in fit_generator
use_multiprocessing=use_multiprocessing)
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/Users/apple/Documents/Custom_MaskRCNN/myenv345/lib/python3.6/site-packages/keras/engine/training.py", line 2160, in evaluate_generator
generator_output = next(output_generator)
StopIteration`
and here is my custom code
My Code:
`
import os
import sys
import json
import datetime
import numpy as np
import skimage.draw
import imgaug
import warnings
warnings.filterwarnings("ignore")
Root directory of the project
ROOT_DIR = os.path.abspath("../../")
Import Mask RCNN
sys.path.append(ROOT_DIR) # To find local version of the library
from mrcnn.config import Config
from mrcnn import model as modellib, utils
Path to trained weights file
COCO_WEIGHTS_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
Directory to save logs and model checkpoints, if not provided
through the command line argument --logs
DEFAULT_LOGS_DIR = os.path.join(ROOT_DIR, "logs")
############################################################
Configurations
############################################################
class CustomConfig(Config):
NAME = "object"
IMAGES_PER_GPU = 2
NUM_CLASSES = 1 + 8 # Background + number of classes (Here, 2)
STEPS_PER_EPOCH = 100
DETECTION_MIN_CONFIDENCE = 0.9
############################################################
Dataset
############################################################
class CustomDataset(utils.Dataset):
def train(model):
"""Train the model."""
dataset_train = CustomDataset()
dataset_train.load_custom(args.dataset, "train")
dataset_train.prepare()
def color_splash(image, mask):
gray = skimage.color.gray2rgb(skimage.color.rgb2gray(image)) * 255
if mask.shape[-1] > 0:
mask = (np.sum(mask, -1, keepdims=True) >= 1)
splash = np.where(mask, image, gray).astype(np.uint8)
else:
splash = gray.astype(np.uint8)
return splash
def detect_and_color_splash(model, image_path=None, video_path=None):
if image_path:
print("Running on {}".format(args.image))
image = skimage.io.imread(args.image)
r = model.detect([image], verbose=1)[0]
splash = color_splash(image, r['masks'])
file_name = "splash_{:%Y%m%dT%H%M%S}.png".format(datetime.datetime.now())
skimage.io.imsave(file_name, splash)
elif video_path:
import cv2
vcapture = cv2.VideoCapture(video_path)
width = int(vcapture.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(vcapture.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = vcapture.get(cv2.CAP_PROP_FPS)
file_name = "splash_{:%Y%m%dT%H%M%S}.avi".format(datetime.datetime.now())
vwriter = cv2.VideoWriter(file_name,
cv2.VideoWriter_fourcc(*'MJPG'),
fps, (width, height))
############################################################
Training
############################################################
if name == 'main':
import argparse
The text was updated successfully, but these errors were encountered: