models icon indicating copy to clipboard operation
models copied to clipboard

keep_aspect_ratio_resizer for variable sized images with batch_size > 1

Open mirayyuce opened this issue 7 years ago • 2 comments

I am using KITTI's object detection dataset to train a Faster R-CNN with ResNet 101, pretrained on MS COCO. KITTI images "mostly" of dimension 375x1242

When I had batch_size: 1, everything was perfect. My keep_aspect_ratio_resizer was like below, as it was proposed by TensorFlow itself.

min_dimension: 600
max_dimension: 1987

But now I want to use batch_size: 5, but I keep getting dimension mismatch errors. Because some of the images have a slightly smaller size, like 370x1224 etc.

I can't find a general keep_aspect_ratio_resizer values. I tried the below values based one the values I saw in the error messages, but I can't make all images the same size really

min_dimension: 600
max_dimension: 1985


min_dimension: 599
max_dimension: 1985

What could be good value for keeping the ratio? I don't want to use pad_to_max_dimension

mirayyuce avatar Mar 14 '19 17:03 mirayyuce

Fixed by adding tf.image.resize_image_with_crop_or_pad(images, max_height, max_width) to create_input_queue() in https://github.com/tensorflow/models/blob/master/research/object_detection/legacy/trainer.py

mirayyuce avatar Mar 14 '19 20:03 mirayyuce

I think this is a bug, can you send a pr to fix it?

rootkitchao avatar Mar 14 '19 21:03 rootkitchao