2gunsu / monocon-pytorch

Unofficial Pytorch Implementation for MonoCon(AAAI, 2022)
Apache License 2.0
86 stars 10 forks source link

Resize the input image #1

Closed PeterH0323 closed 2 years ago

PeterH0323 commented 2 years ago

안녕하세요.

Thanks for your great great great job!

I want to resize my image while training , what should I do ?

Please give me some advice or maybe you can add it in the code 😄

2gunsu commented 2 years ago

Hello. Thanks for your interest in my code. Like other papers, this code applies only padding so that the resolution of the image is a multiple of 32, and does not consider resizing at all.

Currently, I am personally implementing the resize transform that can be applied to 3d detection, and I will update the code when the implementation is complete. Thanks again for your interest. 😊

PeterH0323 commented 2 years ago

OK, looking forward to it .

감사합니다.

2gunsu commented 2 years ago

Hello. The transform that resizes the image and label has been updated in the code.

The default transforms used in the training are as follows. (Can be found in dataset/monocon_dataset.py)

default_train_transforms = [
    PhotometricDistortion(
        brightness_delta=32,
        contrast_range=(0.5, 1.5),
        saturation_range=(0.5, 1.5),
        hue_delta=18),
    RandomShift(prob=0.5, shift_range=(-32, 32), hide_kpts_in_shift_area=True),
    RandomHorizontalFlip(prob=0.5),
    RandomCrop3D(prob=0.5, crop_size=(320, 960), hide_kpts_in_crop_area=True),
    Normalize(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375]),
    Pad(size_divisor=32),
    ToTensor(),
]

If you want to resize the image to (256, 768), set the first element of the transform list as Resize3D(target_hw=(256, 768)) as shown below. Since the size of the image has changed, when performing a transform that requires a size parameter like RandomCrop3D, you need to set this parameter smaller than the image size.

default_train_transforms = [
    Resize3D(target_hw=(256, 768)),
    PhotometricDistortion(
        brightness_delta=32,
        contrast_range=(0.5, 1.5),
        saturation_range=(0.5, 1.5),
        hue_delta=18),
    RandomShift(prob=0.5, shift_range=(-32, 32), hide_kpts_in_shift_area=True),
    RandomHorizontalFlip(prob=0.5),
    RandomCrop3D(prob=0.5, crop_size=(256, 320), hide_kpts_in_crop_area=True),
    Normalize(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375]),
    Pad(size_divisor=32),
    ToTensor(),
]

Also, if you want to perform resizing during validation or testing, add Resize3D to default_test_transforms as shown below.

default_test_transforms = [
    Resize3D(target_hw=(256, 768)),
    Normalize(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375]),
    Pad(size_divisor=32),
    ToTensor(),
]

Actually, I don't know how the performance will be if the resizing proceeds. 🤔 Have a nice day!

PeterH0323 commented 2 years ago

안녕하세요. I will try it. Thx for your great great great job ! 감사합니다 !