Skip to content

ERROR in get_flops.py when computing FLOPs and Params for SAN model due to SideAdapterCLIPHead forward signature mismatch #3866

Description

@Life-if

我使用 mmseg 版本为 1.2.2 。当我想要运行 get_flops.py 计算 SAN 分割模型的计算量和参数量的时候会发生报错。

I am using MMSEG version 1.2.2. When I want to run 'get_flops. py' to calculate the FLOPs and Param of the SAN segmentation model, an error occurs.

具体来说,当我运行

python mmsegmentation/tools/analysis_tools/get_flops.py san-vit-b16_xxx-640x640.py --shape 1024

或者相关命令的时候会发生报错

TypeError: SideAdapterCLIPHead.forward() missing 1 required positional argument: 'deep_supervision_idxs'

具体原因在于,SAN 的 decode_head 在进行前向计算的时候需要deep_supervision_idxs这个参数,但是构建用的 MultimodalEncoderDecoder 采用的方法是将 encoder 的结果直接输入 decoder 中。而如果直接在代码中加上该形参试图解决该问题的话,编码器得到的 x 与解码器需要的 x之间也存在出入,比如:

File "mmsegmentation/mmseg/models/decode_heads/san_head.py", line 542, in forward
    imgs, clip_feature, class_embeds = inputs
ValueError: too many values to unpack (expected 3)

因为传入的 len(x)=4

因为该模型不是我主要关注的问题,受限于时间,目前我的解决方法是暂时不计算解码器,因为主要的参数量和计算量都在编码器部分。

后续可以观察一下该问题是否在最新版本中是否能够复现,以及是否是有可能是环境版本的问题或者本人个人的配置问题,并对此 issue 进行修复。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions