Question about `align_corners=True`
See original GitHub issueHi, dear authors!
Sorry to bother you.
I have a question about align_corners=True
I want to set align_corners=True
to improve Dice metric,but when I set align_corners=True
, the following warning always appears:
train: UserWarning: When align_corners=True, the output would more aligned if input size (80, 80) is x+1
and out size (320, 320) is nx+1
val: UserWarning: When align_corners=True, the output would more aligned if input size (104, 104) is x+1
and out size (416, 416) is nx+1
Here is my config about train_pipeline
and test_pipeline
:
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(type='Resize',
img_scale=[(320, 320), (416, 416)],
keep_ratio=True),
dict(type='RandomCrop',
crop_size=crop_size,
cat_max_ratio=0.9),
dict(type='RandomFlip', prob=0.5),
dict(
type='Albu',
transforms=albu_train_transforms,
keymap=dict(img='image', gt_semantic_seg='mask'),
update_pad_shape=False),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(416, 416),
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
Could you tell me how to usealign_corners=True
correctly? How to fix this config up?
Thank you!
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
What we should use align_corners = False - PyTorch Forums
When align_corners=True , pixels are regarded as a grid of points. Points at the corners are aligned. When align_corners=False , pixels are ...
Read more >You might have misundertood the meaning of “align_corners”.
With align_corners=True, pixels are regarded as a grid of points. The points at the “corners” are “aligned”, which means that the 4 new ......
Read more >tf.image.resize_bilinear()-when align_corners=False
When I use tf.image.resize_bilinear() with align_corners=True in the following program: import tensorflow as tf sess = tf.Session() x = tf.
Read more >Dmytro Mishkin @ducha_aiki@sigmoid.social on Twitter ...
Visual explanation of the pytorch grid_sample(align_corners=True/False) ... "Chess teaches problem solving, critical thinking, and patience.
Read more >Upsampling in Core ML - Machine, Think!
With align_corners=True , it preserves the corner points of the input tensor. Sounds like a good thing, but the consequence is that this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you can read Chinese, this link may help you: https://zhuanlan.zhihu.com/p/87572724 In short, use align_corners=True when you rescale image from x+1 to nx+1, and use align_corners=False when you rescale image from x to nx.
I am not an expert on this, it seems that you also need to ensure that the original image is with odd number of resolution. I usally use align_coners=False with even number of resolution. Some papers, e.g. max-deeplab will use 1025x1025 and 641x641 as the resolution. You may need to check their implementations to figure it out. This will emprically improve the performance in dense predictions.