question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

crop_size and img_scale order

See original GitHub issue

In base dataset-related configs you usually have something like, e.g. in cityscapes

crop_size = (512, 1024)
train_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(type='LoadAnnotations'),
    dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)),

does it mean that crop_size has height-width order while img_scale in Resize has width-height order as cityscapes is obviously has the width equal to ~2x of the height and crops are expected to have similar ratio?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
xvjiaruicommented, Jul 24, 2020

Hi @nizhib For term size, we usually use hight-width order in this codebase. For term img_scale in Resize transform, the order doesn’t matter. The smaller one will be considered as the short side, the larger one will be considered as the long side. Specifically, img_scale=(2048, 1024) means the max scale of the resized image is of long side 2048, short side 1024.

0reactions
ParashRahmancommented, Dec 7, 2022

After investigating, I found that mmcv.imresize takes in (w,h) while mmcv.pad takes in (h,w). When img_scale=(w,h) is passed as a tuple to mmseg with no other scaling parameters, it is passed to mmcv.imresize(w,h) properly.

The way mmseg uses mmcv needs crop and pad to be (h, w).

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Display an Image Resized and Cropped - Stack Overflow
I want to show an image from an URL with a certain width and height even if it has a different size ratio....
Read more >
Part 2: Scale and Crop Images - SERC - Carleton
Order, download, and unzip the data on your computer. Use both cropping and scaling to reduce the images to a smaller size.
Read more >
CropSize Review: Bulk Photo Processing and Resizing App ...
CropSize is an iPad app that allows you to easily resize a batch of images and save them all for Web. Or resize...
Read more >
Source code for torchvision.transforms.transforms - PyTorch
If size is an int instead of sequence like (h, w), a square crop (size, size) is made. If provided a tuple or...
Read more >
CropSize - Image Size Editor on the App Store - Apple
Offers over 75 features for Crop, Edit, Resize, Filter, Metadata and other tools for single photo and group of photos.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found