class documentation
class GRL(nn.Module): (source)
Constructor: GRL(img_size, in_channels, out_channels, embed_dim, ...)
Image restoration transformer with global, non-local, and local connections
| Parameters | |
| img | Input image size. Default 64 |
| in | Number of input image channels. Default: 3 |
| out | Number of output image channels. Default: None |
| embed | Patch embedding dimension. Default: 96 |
| upscale | Upscale factor. 2/3/4/8 for image SR, 1 for denoising and compress artifact reduction |
| img | Image range. 1. or 255. |
| upsampler | The reconstruction reconstruction module. 'pixelshuffle'/'pixelshuffledirect'/'nearest+conv'/None |
| depths | Depth of each Swin Transformer layer. |
| num | Number of window attention heads in different layers. |
| num | Number of stripe attention heads in different layers. |
| window | Window size. Default: 8. |
| stripe | Stripe size. Default: [8, 8] |
| stripe | Number of stripe groups. Default: [None, None]. |
| stripe | whether to shift the stripes. This is used as an ablation study. |
| mlp | Ratio of mlp hidden dim to embedding dim. Default: 4 |
| qkv | If True, add a learnable bias to query, key, value. Default: True |
| qkv | QKV projection type. Default: linear. Choices: linear, separable_conv. |
| anchor | Anchor projection type. Default: avgpool. Choices: avgpool, maxpool, conv2d, separable_conv, patchmerging. |
| anchor | Whether to use one operator or multiple progressive operators to reduce feature map resolution. Default: True. |
| anchor | The downscale factor used to get the anchors. |
| out | Type of the output projection in the self-attention modules. Default: linear. Choices: linear, conv2d. |
| local | Whether to enable the local modelling module (two convs followed by Channel attention). For GRL base model, this is used. |
| drop | Dropout rate. Default: 0 |
| attn | Attention dropout rate. Default: 0 |
| drop | Stochastic depth rate. Default: 0.1 |
| pretrained | pretrained window size. This is actually not used. Default: [0, 0]. |
| pretrained | pretrained stripe size. This is actually not used. Default: [0, 0]. |
| norm | Normalization layer. Default: nn.LayerNorm. |
| conv | The convolutional block before residual connection. Default: 1conv. Choices: 1conv, 3conv, 1conv1x1, linear |
| init | initialization method of the weight parameters used to train large scale models.
|
| fairscale | Whether to use fairscale checkpoint. |
| offload | used by fairscale_checkpoint |
| euclidean | use Euclidean distance or inner product as the similarity metric. An ablation study. |
| Method | __init__ |
Undocumented |
| Method | check |
Undocumented |
| Method | forward |
Undocumented |
| Method | forward |
Undocumented |
| Method | get |
Undocumented |
| Method | no |
Undocumented |
| Method | no |
Undocumented |
| Method | set |
Two used cases: 1) At initialization: set the shared buffers. 2) During forward pass: get the new buffers if the resolution of the input changes |
| Class Variable | hyperparameters |
Undocumented |
| Instance Variable | anchor |
Undocumented |
| Instance Variable | conv |
Undocumented |
| Instance Variable | conv |
Undocumented |
| Instance Variable | conv |
Undocumented |
| Instance Variable | conv |
Undocumented |
| Instance Variable | embed |
Undocumented |
| Instance Variable | img |
Undocumented |
| Instance Variable | in |
Undocumented |
| Instance Variable | input |
Undocumented |
| Instance Variable | layers |
Undocumented |
| Instance Variable | mean |
Undocumented |
| Instance Variable | norm |
Undocumented |
| Instance Variable | norm |
Undocumented |
| Instance Variable | out |
Undocumented |
| Instance Variable | pad |
Undocumented |
| Instance Variable | pos |
Undocumented |
| Instance Variable | pretrained |
Undocumented |
| Instance Variable | pretrained |
Undocumented |
| Instance Variable | shift |
Undocumented |
| Instance Variable | stripe |
Undocumented |
| Instance Variable | stripe |
Undocumented |
| Instance Variable | upsample |
Undocumented |
| Instance Variable | upsampler |
Undocumented |
| Instance Variable | upscale |
Undocumented |
| Instance Variable | window |
Undocumented |
| Method | _init |
Undocumented |
def __init__(self, *, img_size=64, in_channels: 6, 6, 6, 6, 6, 6], num_heads_window: 3, 3, 3, 3, 3, 3], num_heads_stripe: 3, 3, 3, 3, 3, 3], window_size=8, stripe_size: 8, 8], stripe_groups: None, None], stripe_shift=False, mlp_ratio=4.0, qkv_bias=True, qkv_proj_type='linear', anchor_proj_type='avgpool', anchor_one_stage=True, anchor_window_down_factor=1, out_proj_type: 0, 0], pretrained_stripe_size: 0, 0], conv_type='1conv', init_method='n', fairscale_checkpoint=False, offload_to_cpu=False, euclidean_dist=False):
(source)
¶
int = 3, out_channels: int = 3, embed_dim=96, upscale=1, img_range=1.0, upsampler='', depths: list[ int] = [list[ int] = [list[ int] = [list[ int] = [list[ (int|None)] = [Literal[ 'linear', 'conv2d'] = 'linear', local_connection=False, drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.1, norm_layer=nn.LayerNorm, pretrained_window_size: list[ int] = [list[ int] = [Undocumented