pyiqa.archs.uranker_arch

URanker model.

This file contains the code for the URanker model, as described in the paper:

Underwater Ranker: Learn Which Is Better and How to Be Better Chunle Guo#, Ruiqi Wu#, Xin Jin, Linghao Han, Zhi Chai, Weidong Zhang, Chongyi Li* Proceedings of the AAAI conference on artificial intelligence (AAAI), 2023

Official codes: https://github.com/RQ-Wu/UnderwaterRanker

Module Contents

pyiqa.archs.uranker_arch.default_model_urls[source]
pyiqa.archs.uranker_arch.padding_img(img)[source]
pyiqa.archs.uranker_arch.build_historgram(img)[source]
pyiqa.archs.uranker_arch.preprocessing(d_img_org)[source]
class pyiqa.archs.uranker_arch.Mlp(in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.0)[source]

Bases: torch.nn.Module

Feed-forward network (FFN, a.k.a. MLP) class.

forward(x)[source]
class pyiqa.archs.uranker_arch.ConvRelPosEnc(Ch, h, window)[source]

Bases: torch.nn.Module

Convolutional relative position encoding.

forward(q, v, size)[source]
class pyiqa.archs.uranker_arch.FactorAtt_ConvRelPosEnc(dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0.0, proj_drop=0.0, shared_crpe=None)[source]

Bases: torch.nn.Module

Factorized attention with convolutional relative position encoding class.

forward(x, size)[source]
class pyiqa.archs.uranker_arch.ConvPosEnc(dim, k=3)[source]

Bases: torch.nn.Module

Convolutional Position Encoding. Note: This module is similar to the conditional position encoding in CPVT.

forward(x, size)[source]
class pyiqa.archs.uranker_arch.SerialBlock(dim, num_heads, mlp_ratio=4.0, qkv_bias=False, qk_scale=None, drop=0.0, attn_drop=0.0, drop_path=0.0, act_layer=nn.GELU, norm_layer=nn.LayerNorm, shared_cpe=None, shared_crpe=None)[source]

Bases: torch.nn.Module

Serial block class. Note: In this implementation, each serial block only contains a conv-attention and a FFN (MLP) module.

forward(x, size)[source]
class pyiqa.archs.uranker_arch.ParallelBlock(dims, num_heads, mlp_ratios=[], qkv_bias=False, qk_scale=None, drop=0.0, attn_drop=0.0, drop_path=0.0, act_layer=nn.GELU, norm_layer=nn.LayerNorm, shared_cpes=None, shared_crpes=None, connect_type='neighbor')[source]

Bases: torch.nn.Module

Parallel block class.

upsample(x, output_size, size)[source]

Feature map up-sampling.

downsample(x, output_size, size)[source]

Feature map down-sampling.

interpolate(x, output_size, size)[source]

Feature map interpolation.

forward(x1, x2, x3, x4, sizes)[source]
class pyiqa.archs.uranker_arch.PatchEmbed(patch_size=16, in_chans=3, embed_dim=768)[source]

Bases: torch.nn.Module

Image to Patch Embedding

forward(x)[source]
class pyiqa.archs.uranker_arch.URanker(patch_size=4, in_chans=3, num_classes=1, embed_dims=[152, 320, 320, 320], serial_depths=[2, 2, 2, 2], parallel_depth=6, num_heads=8, mlp_ratios=[4, 4, 4, 4], qkv_bias=True, qk_scale=None, drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.0, norm_layer=partial(nn.LayerNorm, eps=1e-06), return_interm_layers=False, out_features=None, crpe_window={3: 2, 5: 3, 7: 3}, add_historgram=True, his_channel=192, connect_type='dynamic', pretrained=True, pretrained_model_path=None, **kwargs)[source]

Bases: torch.nn.Module

no_weight_decay()[source]
get_classifier()[source]
reset_classifier(num_classes, global_pool='')[source]
insert_cls(x, cls_token)[source]

Insert CLS token.

insert_his(x, his_token)[source]
remove_token(x)[source]

Remove CLS token.

forward_features(x0, x_his)[source]
forward(x)[source]