matterport / Mask_RCNN

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

Number of images formed after augmentation? #2206

Open rupa1118 opened 4 years ago

rupa1118 commented 4 years ago

Hi, I'm using augmentation to avoid overfitting can someone tell how to find the size of the dataset after applying the augmentation technique?

suchiz commented 4 years ago

Hi there, augmentation uses a generator. You actually choose the number of the image generated with the STEP_PER_EPOCHS variable.

rupa1118 commented 4 years ago

Hi @suchiz can you please explain in brief? How can STEP_PER_EPOCHS help in finding the number of images generated using STEPS_PER_EPOCHS???

Thanks

suchiz commented 4 years ago

Hi there :)

As you may know in model.py, at the train function, they use data generator and train with keras.fit_generator. Those generators will prepare the next batch everytime it is needed (number of step). So if you put 1000 steps per epoch, with a batch of 1. Then the generator will generate 1 images 1000 times (NB of step) so your training set will be 1000 images. You can check out data_generator function too if it can helps. I'm not sure if I'm clear, come back if not. I'll try to give more details (if it is still in my knowledge).

rupa1118 commented 4 years ago

Hi @suchiz I have seen the code but couldn't understand can you please help me by explaining in detail about it? if the configuration file consists of 100 steps per epoch with batch size 4 then how many images are generated for a single image??

lucasbens commented 1 year ago

"Why do we need steps_per_epoch ?

Keep in mind that a Keras data generator is meant to loop infinitely — it should never return or exit.

Since the function is intended to loop infinitely, Keras has no ability to determine when one epoch starts and a new epoch begins.

Therefore, we compute the steps_per_epoch value as the total number of training data points divided by the batch size. Once Keras hits this step count it knows that it’s a new epoch."

Source: https://pyimagesearch.com/2018/12/24/how-to-use-keras-fit-and-fit_generator-a-hands-on-tutorial/