matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.57k stars 11.69k forks source link

How many images are randomly cropped per image? #582

Open cklat opened 6 years ago

cklat commented 6 years ago

Hi,

I'm still trying to sort out, how many images are randomly cropped from an image if your config is in the 'cropping' mode? Say you have a 1024x1024 image and you are setting 512x512 crops. If you presume you don't want to have overlapping images, there could be theoretically 4 different images cropped. Is this the case or is only one random 512x512 image cropped that could be located anywhere in the original image? If it's the latter, what is the suggested setting for the number of steps per epoch? As far as I know, the usual setting is #Images/#Images_per_gpu but if it's only cropping one 512x512 image this is obviously too low and potential training data is wasted. Obviously, one solution would be to set the number just higher but how can I assure that I get the most out of my original images (e.g. best case: 4 images that are not overlapping)

Thanks for the help!

JaledMC commented 5 years ago

Hi,

It takes only one cropped image for iteration. From utils.py:

elif mode == "crop":
        # Pick a random crop
        h, w = image.shape[:2]
        y = random.randint(0, (h - min_dim))
        x = random.randint(0, (w - min_dim))
        crop = (y, x, min_dim, min_dim)
        image = image[y:y + min_dim, x:x + min_dim]
window = (0, 0, min_dim, min_dim)

The coordinates are random, and two crops from different iterations on the same image can overlap. It works like a type of data augmentation. You can increase the number of iterations to be sure that all pixels in the image pass through the model.