fizyr / keras-retinanet

Keras implementation of RetinaNet object detection.
Apache License 2.0
4.38k stars 1.96k forks source link

Do images need to be resized prior to training? #519

Closed bw4sz closed 6 years ago

bw4sz commented 6 years ago

My use case is slightly different than standard benchmark data. I am performing detection within image crops from a very large satellite tile. Other parts of the pipeline generate the crops, which cuts down on the number of boxes needed to predict (there are thousands of objects on the overall tile). Since crops are generated on the fly, they will all have different sizes and aspect ratios. Should I preformat them, or does retinanet scale them, along with the bounding boxes?

I can see that the generator method looks at the aspect ratio. And specifies an argument. Given that i'll probably keep batch_size=1, this means that I don't need to resize crops as they are passed to retinanet?

hgaiser commented 6 years ago

The network itself doesn't resize images, nor does it require a static size or anything. It only expects 3D images where the last dimension has 3 channels. The generators do resize images. This is done to put a limit on the data being passed through the network. If you're positive your images will fit in your GPU memory, you could write (or alter) a generator that doesn't resize images at all.

On Wed, 20 Jun 2018, 22:39 Ben Weinstein, notifications@github.com wrote:

My use case is slightly different than standard benchmark data. I am performing detection within image crops from a very large satellite tile. Other parts of the pipeline generate the crops, which cuts down on the number of boxes needed to predict (there are thousands of objects on the overall tile). Since crops are generated on the fly, they will all have different sizes and aspect ratios. Should I preformat them, or does retinanet scale them, along with the bounding boxes?

I can see https://github.com/bw4sz/keras-retinanet/blob/a2cada4dd90530d34f119a8aba36de1bb063f7dd/keras_retinanet/preprocessing/generator.py#L96 that the generator method looks at the aspect ratio. And specifies an argument https://github.com/bw4sz/keras-retinanet/blob/a2cada4dd90530d34f119a8aba36de1bb063f7dd/keras_retinanet/preprocessing/generator.py#L57. Given that i'll probably keep batch_size=1, this means that I don't need to resize crops as they are passed to retinanet?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fizyr/keras-retinanet/issues/519, or mute the thread https://github.com/notifications/unsubscribe-auth/AArtanJtmBAkHqrzf4ND7_BAZE7nEAUvks5t-rMXgaJpZM4Uv82p .

bw4sz commented 6 years ago

perfect. Its always tricky to know if all crops will fit, but i'm going to risk it. Most should be pretty small. I'm rewriting a generator now to take in crops on the fly, rather than reading from file. Thanks for quick response.