Mask_RCNN
Mask_RCNN copied to clipboard
Training with Grey images dataset
These are the steps that I have followed so far for my grey scale dataset.
Step 1
> class DetectorConfig(Config):
> """Configuration for training pneumonia detection on the RSNA pneumonia dataset.
> Overrides values in the base Config class https://github.com/matterport/Mask_RCNN/blob/master/mrcnn/config.py.
> """
> IMAGE_CHANNEL_COUNT = 1
> MEAN_PIXEL = [123.7] # this value is the one that I chose
Step 2
> def load_image(self, image_id):
> # Load image
> image = skimage.io.imread(self.image_info[image_id]['path'])
> # Convert to grayscale for consistency.
> if image.ndim != 1:
> image = skimage.color.gray2rgb(image) #Instead of rgb2gray(image)
>
> # Extending the size of the image to be (h,w,1)
> image = image[..., np.newaxis]
> return image```
Alternate Step 2
> def load_image(self, image_id):
> """Load the specified image and return a [H,W,3] Numpy array.
> """
> # Load image
> image = skimage.io.imread(self.image_info[image_id]['path'])
> image = image[..., np.newaxis] # Extending the size of the image to be (h,w,1)
> return image
Step 3
> model.load_weights(COCO_MODEL_PATH, by_name=True,
> exclude=["mrcnn_class_logits", "mrcnn_bbox_fc",
> "mrcnn_bbox", "mrcnn_mask", "conv1"])
Step 4
> layer_regex = {
> # all layers but the backbone
> "heads": r"(conv1\_.*)|(mrcnn\_.*)|(rpn\_.*)|(fpn\_.*)",
>
> def load_image(self, image_id):
> image = image[..., np.newaxis]
** Step 5 **
> def resize_image(image, min_dim=None, max_dim=None, min_scale=None, mode="square"):
> padding = [(top_pad, bottom_pad), (left_pad, right_pad)]
> image = np.pad(image, padding, mode='constant', constant_values=0)
>
Step 6
> > if len(image.shape) != 3 or image.shape[2] != 3:
> image = np.squeeze(image, axis = -1)
> image = np.stack((image,) * 3, -1)
When I run this code, I faced this issue from train(model)
ValueError: len(output_shape) cannot be smaller than the image dimensions
The issue is different if I used "rgb2gray(image)" instead at Step 2
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (3,2)
Alternate step 2
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (3,2)
Please provide some assistance.
Just did this on utils
> def load_image(self, image_id):
> """Load the specified image and return a [H,W,3] Numpy array.
> # Load image
> image = cv2.imread(self.image_info[image_id]['path'])
> image = image[..., np.newaxis] # Extending the size of the image to be (h,w,1)
> return image
Result
ValueError: len(output_shape) cannot be smaller than the image dimensions
Dataset images are of all same dimensions.
~\AppData\Roaming\Python\Python36\site-packages\skimage\transform\_warps.py in resize(image, output_shape, order, mode, cval, clip, preserve_range, anti_aliasing, anti_aliasing_sigma)
98 output_shape = output_shape + (image.shape[-1], )
99 elif output_ndim < image.ndim - 1:
--> 100 raise ValueError("len(output_shape) cannot be smaller than the image "
101 "dimensions")
102
ValueError: len(output_shape) cannot be smaller than the image dimensions
I had tried to trace and the error comes out from _warps.py file. Is there a need to edit this file?
I receive same error as you did above How did you solve it? If you did
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (3,2) and requested shape (2,2)
Hi, I've followed all the steps but I still get an error at the beginning of my training (Error when checking input: expected input_image to have shape (None, None, 1) but got array with shape (404, 404, 3)) and I don't see why i get it.
Getting this same error
ValueError: len(output_shape) cannot be smaller than the image dimensions
Anyone solved this??