pyiqa.archs.uranker_arch ======================== .. py:module:: pyiqa.archs.uranker_arch .. autoapi-nested-parse:: 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 --------------- .. py:data:: default_model_urls .. py:function:: padding_img(img) .. py:function:: build_historgram(img) .. py:function:: preprocessing(d_img_org) .. py:class:: Mlp(in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.0) Bases: :py:obj:`torch.nn.Module` Feed-forward network (FFN, a.k.a. MLP) class. .. py:method:: forward(x) .. py:class:: ConvRelPosEnc(Ch, h, window) Bases: :py:obj:`torch.nn.Module` Convolutional relative position encoding. .. py:method:: forward(q, v, size) .. py:class:: FactorAtt_ConvRelPosEnc(dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0.0, proj_drop=0.0, shared_crpe=None) Bases: :py:obj:`torch.nn.Module` Factorized attention with convolutional relative position encoding class. .. py:method:: forward(x, size) .. py:class:: ConvPosEnc(dim, k=3) Bases: :py:obj:`torch.nn.Module` Convolutional Position Encoding. Note: This module is similar to the conditional position encoding in CPVT. .. py:method:: forward(x, size) .. py:class:: 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) Bases: :py:obj:`torch.nn.Module` Serial block class. Note: In this implementation, each serial block only contains a conv-attention and a FFN (MLP) module. .. py:method:: forward(x, size) .. py:class:: 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') Bases: :py:obj:`torch.nn.Module` Parallel block class. .. py:method:: upsample(x, output_size, size) Feature map up-sampling. .. py:method:: downsample(x, output_size, size) Feature map down-sampling. .. py:method:: interpolate(x, output_size, size) Feature map interpolation. .. py:method:: forward(x1, x2, x3, x4, sizes) .. py:class:: PatchEmbed(patch_size=16, in_chans=3, embed_dim=768) Bases: :py:obj:`torch.nn.Module` Image to Patch Embedding .. py:method:: forward(x) .. py:class:: 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) Bases: :py:obj:`torch.nn.Module` .. py:method:: no_weight_decay() .. py:method:: get_classifier() .. py:method:: reset_classifier(num_classes, global_pool='') .. py:method:: insert_cls(x, cls_token) Insert CLS token. .. py:method:: insert_his(x, his_token) .. py:method:: remove_token(x) Remove CLS token. .. py:method:: forward_features(x0, x_his) .. py:method:: forward(x)