Skip to content

Commit

Permalink
Merge branch '1.x' into dev-1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mzr1996 committed Oct 10, 2022
2 parents dfb4e87 + 2153a16 commit 043574c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 48 deletions.
1 change: 1 addition & 0 deletions docs/en/api/data_process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ And you can also configure a group of policies manually by selecting from the be
Solarize
SolarizeAdd
Translate
BaseAugTransform

Formatting
^^^^^^^^^^
Expand Down
10 changes: 5 additions & 5 deletions mmcls/datasets/transforms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .auto_augment import (AutoAugment, AutoContrast, Brightness,
ColorTransform, Contrast, Cutout, Equalize, Invert,
Posterize, RandAugment, Rotate, Sharpness, Shear,
Solarize, SolarizeAdd, Translate)
from .auto_augment import (AutoAugment, AutoContrast, BaseAugTransform,
Brightness, ColorTransform, Contrast, Cutout,
Equalize, Invert, Posterize, RandAugment, Rotate,
Sharpness, Shear, Solarize, SolarizeAdd, Translate)
from .formatting import Collect, PackClsInputs, ToNumpy, ToPIL, Transpose
from .processing import (Albumentations, ColorJitter, EfficientNetCenterCrop,
EfficientNetRandomCrop, Lighting, RandomCrop,
Expand All @@ -15,5 +15,5 @@
'Contrast', 'Brightness', 'Sharpness', 'AutoAugment', 'SolarizeAdd',
'Cutout', 'RandAugment', 'Lighting', 'ColorJitter', 'RandomErasing',
'PackClsInputs', 'Albumentations', 'EfficientNetRandomCrop',
'EfficientNetCenterCrop', 'ResizeEdge'
'EfficientNetCenterCrop', 'ResizeEdge', 'BaseAugTransform'
]
50 changes: 26 additions & 24 deletions mmcls/datasets/transforms/auto_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class Shear(BaseAugTransform):
Args:
magnitude (int | float | None): The magnitude used for shear. If None,
generate from ``magnitude_range``, see :class:`AugTransform`.
generate from ``magnitude_range``, see :class:`BaseAugTransform`.
Defaults to None.
pad_val (int, Sequence[int]): Pixel pad_val value for constant fill.
If a sequence of length 3, it is used to pad_val R, G, B channels
Expand All @@ -375,7 +375,7 @@ class Shear(BaseAugTransform):
negative, which should be in range [0,1]. Defaults to 0.5.
interpolation (str): Interpolation method. Options are 'nearest',
'bilinear', 'bicubic', 'area', 'lanczos'. Defaults to 'bicubic'.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -444,7 +444,7 @@ class Translate(BaseAugTransform):
that the offset is calculated by magnitude * size in the
corresponding direction. With a magnitude of 1, the whole image
will be moved out of the range. If None, generate from
``magnitude_range``, see :class:`AugTransform`.
``magnitude_range``, see :class:`BaseAugTransform`.
pad_val (int, Sequence[int]): Pixel pad_val value for constant fill.
If a sequence of length 3, it is used to pad_val R, G, B channels
respectively. Defaults to 128.
Expand All @@ -456,7 +456,7 @@ class Translate(BaseAugTransform):
negative, which should be in range [0,1]. Defaults to 0.5.
interpolation (str): Interpolation method. Options are 'nearest',
'bilinear', 'bicubic', 'area', 'lanczos'. Defaults to 'nearest'.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -528,7 +528,8 @@ class Rotate(BaseAugTransform):
Args:
angle (float, optional): The angle used for rotate. Positive values
stand for clockwise rotation. If None, generate from
``magnitude_range``, see :class:`AugTransform`. Defaults to None.
``magnitude_range``, see :class:`BaseAugTransform`.
Defaults to None.
center (tuple[float], optional): Center point (w, h) of the rotation in
the source image. If None, the center of the image will be used.
Defaults to None.
Expand All @@ -542,7 +543,7 @@ class Rotate(BaseAugTransform):
negative, which should be in range [0,1]. Defaults to 0.5.
interpolation (str): Interpolation method. Options are 'nearest',
'bilinear', 'bicubic', 'area', 'lanczos'. Defaults to 'nearest'.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -610,7 +611,7 @@ class AutoContrast(BaseAugTransform):
Args:
prob (float): The probability for performing auto contrast
therefore should be in range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self, prob: float = 0.5, **kwargs):
Expand Down Expand Up @@ -640,7 +641,7 @@ class Invert(BaseAugTransform):
Args:
prob (float): The probability for performing invert therefore should
be in range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self, prob: float = 0.5, **kwargs):
Expand Down Expand Up @@ -670,7 +671,7 @@ class Equalize(BaseAugTransform):
Args:
prob (float): The probability for performing equalize therefore should
be in range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self, prob: float = 0.5, **kwargs):
Expand Down Expand Up @@ -700,10 +701,10 @@ class Solarize(BaseAugTransform):
Args:
thr (int | float | None): The threshold above which the pixels value
will be inverted. If None, generate from ``magnitude_range``,
see :class:`AugTransform`. Defaults to None.
see :class:`BaseAugTransform`. Defaults to None.
prob (float): The probability for solarizing therefore should be in
range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -746,12 +747,12 @@ class SolarizeAdd(BaseAugTransform):
Args:
magnitude (int | float | None): The value to be added to pixels below
the thr. If None, generate from ``magnitude_range``, see
:class:`AugTransform`. Defaults to None.
:class:`BaseAugTransform`. Defaults to None.
thr (int | float): The threshold below which the pixels value will be
adjusted.
prob (float): The probability for solarizing therefore should be in
range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -801,10 +802,11 @@ class Posterize(BaseAugTransform):
Args:
bits (int, optional): Number of bits for each pixel in the output img,
which should be less or equal to 8. If None, generate from
``magnitude_range``, see :class:`AugTransform`. Defaults to None.
``magnitude_range``, see :class:`BaseAugTransform`.
Defaults to None.
prob (float): The probability for posterizing therefore should be in
range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -855,7 +857,7 @@ class Contrast(BaseAugTransform):
contrast. A positive magnitude would enhance the contrast and
a negative magnitude would make the image grayer. A magnitude=0
gives the origin img. If None, generate from ``magnitude_range``,
see :class:`AugTransform`. Defaults to None.
see :class:`BaseAugTransform`. Defaults to None.
prob (float): The probability for performing contrast adjusting
therefore should be in range [0, 1]. Defaults to 0.5.
random_negative_prob (float): The probability that turns the magnitude
Expand Down Expand Up @@ -908,12 +910,12 @@ class ColorTransform(BaseAugTransform):
A positive magnitude would enhance the color and a negative
magnitude would make the image grayer. A magnitude=0 gives the
origin img. If None, generate from ``magnitude_range``, see
:class:`AugTransform`. Defaults to None.
:class:`BaseAugTransform`. Defaults to None.
prob (float): The probability for performing ColorTransform therefore
should be in range [0, 1]. Defaults to 0.5.
random_negative_prob (float): The probability that turns the magnitude
negative, which should be in range [0,1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -962,12 +964,12 @@ class Brightness(BaseAugTransform):
brightness. A positive magnitude would enhance the brightness and a
negative magnitude would make the image darker. A magnitude=0 gives
the origin img. If None, generate from ``magnitude_range``, see
:class:`AugTransform`. Defaults to None.
:class:`BaseAugTransform`. Defaults to None.
prob (float): The probability for performing brightness adjusting
therefore should be in range [0, 1]. Defaults to 0.5.
random_negative_prob (float): The probability that turns the magnitude
negative, which should be in range [0,1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -1016,12 +1018,12 @@ class Sharpness(BaseAugTransform):
sharpness. A positive magnitude would enhance the sharpness and a
negative magnitude would make the image bulr. A magnitude=0 gives
the origin img. If None, generate from ``magnitude_range``, see
:class:`AugTransform`. Defaults to None.
:class:`BaseAugTransform`. Defaults to None.
prob (float): The probability for performing sharpness adjusting
therefore should be in range [0, 1]. Defaults to 0.5.
random_negative_prob (float): The probability that turns the magnitude
negative, which should be in range [0,1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down Expand Up @@ -1069,13 +1071,13 @@ class Cutout(BaseAugTransform):
shape (int | tuple(int) | None): Expected cutout shape (h, w).
If given as a single value, the value will be used for both h and
w. If None, generate from ``magnitude_range``, see
:class:`AugTransform`. Defaults to None.
:class:`BaseAugTransform`. Defaults to None.
pad_val (int, Sequence[int]): Pixel pad_val value for constant fill.
If it is a sequence, it must have the same length with the image
channels. Defaults to 128.
prob (float): The probability for performing cutout therefore should
be in range [0, 1]. Defaults to 0.5.
**kwargs: Other keyword arguments of :class:`AugTransform`.
**kwargs: Other keyword arguments of :class:`BaseAugTransform`.
"""

def __init__(self,
Expand Down
38 changes: 19 additions & 19 deletions mmcls/models/backbones/twins.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,21 +367,21 @@ class PCPVT(BaseModule):
- strides (List[int]): The strides in each stage.
- mlp_ratios (List[int]): The ratios of mlp in each stage.
- sr_ratios (List[int]): The ratios of GSA-encoder layers in each
stage.
stage.
in_channels (int): Number of input channels. Default: 3.
in_channels (int): Number of input channels. Defaults to 3.
out_indices (tuple[int]): Output from which stages.
Default: (3, ).
qkv_bias (bool): Enable bias for qkv if True. Default: False.
Defaults to ``(3, )``.
qkv_bias (bool): Enable bias for qkv if True. Defaults to False.
drop_rate (float): Probability of an element to be zeroed.
Default 0.
Defaults to 0.
attn_drop_rate (float): The drop out rate for attention layer.
Default 0.0
drop_path_rate (float): Stochastic depth rate. Default 0.0
Defaults to 0.0
drop_path_rate (float): Stochastic depth rate. Defaults to 0.0.
norm_cfg (dict): Config dict for normalization layer.
Default: dict(type='LN')
Defaults to ``dict(type='LN')``.
norm_after_stage(bool, List[bool]): Add extra norm after each stage.
Default False.
Defaults to False.
init_cfg (dict, optional): The Config for initialization.
Defaults to None.
Expand Down Expand Up @@ -613,22 +613,22 @@ class SVT(PCPVT):
- strides (List[int]): The strides in each stage.
- mlp_ratios (List[int]): The ratios of mlp in each stage.
- sr_ratios (List[int]): The ratios of GSA-encoder layers in each
stage.
stage.
- windiow_sizes (List[int]): The window sizes in LSA-encoder layers
in each stage.
in each stage.
in_channels (int): Number of input channels. Default: 3.
in_channels (int): Number of input channels. Defaults to 3.
out_indices (tuple[int]): Output from which stages.
Default: (3, ).
qkv_bias (bool): Enable bias for qkv if True. Default: False.
drop_rate (float): Dropout rate. Default 0.
Defaults to (3, ).
qkv_bias (bool): Enable bias for qkv if True. Defaults to False.
drop_rate (float): Dropout rate. Defaults to 0.
attn_drop_rate (float): Dropout ratio of attention weight.
Default 0.0
drop_path_rate (float): Stochastic depth rate. Default 0.2.
Defaults to 0.0
drop_path_rate (float): Stochastic depth rate. Defaults to 0.2.
norm_cfg (dict): Config dict for normalization layer.
Default: dict(type='LN')
Defaults to ``dict(type='LN')``.
norm_after_stage(bool, List[bool]): Add extra norm after each stage.
Default False.
Defaults to False.
init_cfg (dict, optional): The Config for initialization.
Defaults to None.
Expand Down

0 comments on commit 043574c

Please sign in to comment.