zzzxxxttt / pytorch_simple_CenterNet_45

A simple pytorch implementation of CenterNet (Objects as Points)
308 stars 63 forks source link

It seems the affine transformation in the coco.py force the image into the size of 512x512 #12

Closed songyuc closed 4 years ago

songyuc commented 4 years ago

Hi guys, After reading the code of coco.py, I find that it seems the affine transformation in the coco.py forces the image into the size of 512x512, as

    trans_img = get_affine_transform(center, scale, 0, [self.img_size['w'], self.img_size['h']])
    img = cv2.warpAffine(img, trans_img, (self.img_size['w'], self.img_size['h']))

I am not sure whether this is a general trick to resize the images of different sizes.

Any idea or answer will be appreciated!

zzzxxxttt commented 4 years ago

It is a standard procedure for anchor-free detectors such as CornerNet/ExtremeNet/CenterNet. These models use Hourglass backbone to generate high-resolution output featuremaps, use a higher input resolution will result in much higher computation cost.

songyuc commented 4 years ago

Hi, @zzzxxxttt , thanks for your guide and answer! I think keeping the aspect ratio would be a better choice and seems more reasonable.

zzzxxxttt commented 4 years ago

The preprocessing keeps the aspect ratio of origainal images, it uses zero padding to make them have the same resolution.

songyuc commented 4 years ago

@zzzxxxttt , let me see. More specifically, do you mean the cv2.warpAffine() function will do the zero padding for the absent part of the image?

zzzxxxttt commented 4 years ago

Yes