mmagic.datasets.transforms.random_down_sampling
¶
Module Contents¶
Classes¶
Generate LQ image from GT (and crop), which will randomly pick a scale. |
Functions¶
|
Resize the given image to a given size. |
- class mmagic.datasets.transforms.random_down_sampling.RandomDownSampling(scale_min=1.0, scale_max=4.0, patch_size=None, interpolation='bicubic', backend='pillow')[source]¶
Bases:
mmcv.transforms.BaseTransform
Generate LQ image from GT (and crop), which will randomly pick a scale.
- Parameters
scale_min (float) – The minimum of upsampling scale, inclusive. Default: 1.0.
scale_max (float) – The maximum of upsampling scale, exclusive. Default: 4.0.
patch_size (int) – The cropped lr patch size. Default: None, means no crop.
interpolation (str) – Interpolation method, accepted values are “nearest”, “bilinear”, “bicubic”, “area”, “lanczos” for ‘cv2’ backend, “nearest”, “bilinear”, “bicubic”, “box”, “lanczos”, “hamming” for ‘pillow’ backend. Default: “bicubic”.
backend (str | None) – The image resize backend type. Options are cv2, pillow, None. If backend is None, the global imread_backend specified by
mmcv.use_backend()
will be used. Default: “pillow”.[scale_min (Scale will be picked in the range of) –
scale_max). –
- mmagic.datasets.transforms.random_down_sampling.resize_fn(img, size, interpolation='bicubic', backend='pillow')[source]¶
Resize the given image to a given size.
- Parameters
img (np.ndarray | torch.Tensor) – The input image.
size (int | tuple[int]) – Target size w or (w, h).
interpolation (str) – Interpolation method, accepted values are “nearest”, “bilinear”, “bicubic”, “area”, “lanczos” for ‘cv2’ backend, “nearest”, “bilinear”, “bicubic”, “box”, “lanczos”, “hamming” for ‘pillow’ backend. Default: “bicubic”.
backend (str | None) – The image resize backend type. Options are cv2, pillow, None. If backend is None, the global imread_backend specified by
mmcv.use_backend()
will be used. Default: “pillow”.
- Returns
resized_img, whose type is same as img.
- Return type
np.ndarray | Tensor