I have project in brain tumor classification, but i'm dealing with this error for about 3 weeks, this is the error message
ERROR:
root:Error processing image {'id': 'tumor-44.png', 'source': 'Meningioma',
'path': 'D:\Belajar Machine Learning\Coba Mask Tumor\dataset\images\tumor-44.png'}
Traceback (most recent call last):
File "D:\Belajar Machine Learning\Coba Mask Tumor\mrcnn\model.py", line 1709, in data_generator use_mini_mask=config.USE_MINI_MASK)
File "D:\Belajar Machine Learning\Coba Mask Tumor\mrcnn\model.py", line 1212, in load_image_gt
mask, class_ids = dataset.load_mask(image_id) File "tumor.py", line 228, in load_mask
mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
KeyError: 'height'
I'm so confused with that error message, some people say because something wrong with the json file when I'm mask the image because not using polygon masking, even though I already use polygon for masking.
This is where i'm gonna load my JSON code:
DATASET_PATH = os.path.abspath("dataset")
IMAGES_PATH = os.path.sep.join([DATASET_PATH, "images"])
ANNOT_PATH = os.path.sep.join([DATASET_PATH, "fix.json"])
This is the load_mask
code:
def load_mask(self, imageID):
# Convert polygons to a bitmap mask of shape
# [height, width, instance_count]
info = self.image_info[imageID]
mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
dtype=np.uint8)
for i, p in enumerate(info["polygons"]):
# Get indexes of pixels inside the polygon and set them to 1
rr, cc = skimage.draw.polygon(p['all_points_y'], p['all_points_x'])
## Note that this modifies the existing array arr, instead of creating a result array
## Ref: https://stackoverflow.com/questions/19666626/replace-all-elements-of-python-numpy-array-that-are-greater-than-some-value
rr[rr > mask.shape[0] - 1] = mask.shape[0] - 1
cc[cc > mask.shape[1] - 1] = mask.shape[1] - 1
mask[rr, cc, i] = 1
return mask.astype(np.bool), np.ones([mask.shape[-1]], dtype=np.int32)
I've succeeded the training but i achieve that with round masking, but I want it with polygon masking though.
Thank you.