mmsegmentation icon indicating copy to clipboard operation
mmsegmentation copied to clipboard

How to specify config-file for grayscale images of certain size?

Open jhaggle opened this issue 1 year ago • 5 comments

I am following this tutorial: https://github.com/open-mmlab/mmsegmentation/blob/master/demo/MMSegmentation_Tutorial.ipynb

I am using grayscale images of size (3006,4104). What should the following values in the config be changed to:

cfg.img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)

cfg.crop_size = (256, 256)

cfg.train_pipeline = [ dict(type='Resize', img_scale=(320, 240), ratio_range=(0.5, 2.0)),

jhaggle avatar Sep 19 '22 18:09 jhaggle

img_norm_cfg should keep the same because most pretrained models of MMSegmentation are pretrained based on this image normalization value.

crop_size may be larger because your grayscale images are much larger than normal datasets. But noted that large crop_size may increase GPU memory requirement.

img_scale in Resize may keep the ratio with crop_size, for example, if crop_sizze = (512, 512) then cfg.train_pipeline = [dict(type='Resize', img_scale=(640, 480), ratio_range=(0.5, 2.0)),

MengzhangLI avatar Sep 20 '22 03:09 MengzhangLI

Even if crop_size is bigger, should it always be quadratic, or should/could it be adapted to the aspect ratio of the image?

Could you elaborate your example on how img_scale Resize may keep the ratio with crop_size? How do you mean that the ratio is kept if crop_size = (512, 512) and you then set cfg.train_pipeline = [dict(type='Resize', img_scale=(640, 480)?

Thanks for the quick response!

jhaggle avatar Sep 20 '22 04:09 jhaggle

  1. The setting of crop size is not strict, you may have a try to find a suitable value.

  2. For example, ade20k.py and ade20k_640x640.py.

MengzhangLI avatar Sep 20 '22 05:09 MengzhangLI

So if my grayscale images are of size (3006,4104) and I choose cfg.crop_size = (1024,1024). Does this in anyway affect how I should choose img_scale in dict(type='Resize', img_scale or what should I otherwise take into consideration when setting img_scale?

jhaggle avatar Sep 20 '22 07:09 jhaggle

It depends on your dataset, you can try to find suitable variables by grid search of these hyper parameters.

MengzhangLI avatar Sep 20 '22 09:09 MengzhangLI