Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

the result is very strange #1

Open
pupu-chenyanyan opened this issue Mar 13, 2022 · 5 comments
Open

the result is very strange #1

pupu-chenyanyan opened this issue Mar 13, 2022 · 5 comments

Comments

@pupu-chenyanyan
Copy link

HI,Thank you for great job!
Did you run the code with the mmdet(2.19.0)version ? Can you tell me the result on coco test comparision with original solov2 in the paper? IS there a gap?
And i run the solov2 in mmdet(2.19.0)version on cityscapes,the result is very strange,...can not undertstand. Can you give me some advices,Thank you very much.
frankfurt_000000_000576_leftImg8bit

@lifuguan
Copy link
Owner

lifuguan commented Mar 15, 2022

Results

I'm using 2.19.0 exactly, and the results show no GAP between my implementation and the official version.

Tips

The official checkpoint file should be modified before you use it because the key names don't match.

Code

import torch
import re
dict = torch.load("/disk1/lihao/model_zoo/solo/SOLOv2_R50_1x.pth")
patt='mask_feat_head'
pattern = re.compile(patt)
key_list = list(dict['state_dict'].keys())
for older_val in key_list:
    if len(pattern.findall(older_val)) != 0:
        val = re.sub('mask_feat_head', 'mask_head', older_val)
        dict['state_dict'][val] = dict['state_dict'].pop(older_val)
print(dict['state_dict'].keys())
torch.save(dict, '/disk1/lihao/model_zoo/solo/SOLOv2_fpn_R50_1x.pth')

Example

image

@pupu-chenyanyan
Copy link
Author

pupu-chenyanyan commented Mar 17, 2022 via email

@wptoux
Copy link

wptoux commented Mar 18, 2022

请问为什么要把mask_feat_head替换成mask_head呢?

@lifuguan
Copy link
Owner

请问为什么要把mask_feat_head替换成mask_head呢?

mask_feat_head和mask_head对应mmdet中组件的变量名,类似于backbone,bbox_head

关于mask_feat_head

mask_feat_head是mmdet 1.x版本中single_stage_ins.py中的变量名字

关于mask_head

在mmdet 2.x版本中,single_stage_ins.pybase.py的继承子类,其变量名在mmdet.models.detectors.base.py中已经被定义,如下:

    @property
    def with_mask(self):
        """bool: whether the detector has a mask head"""
        return ((hasattr(self, 'roi_head') and self.roi_head.with_mask)
                or (hasattr(self, 'mask_head') and self.mask_head is not None))

所以,只能修改变量名字以适配mmdet 2.x

@lifuguan
Copy link
Owner

Thank you for great reply. I'm using 2.22.0 mmdet. I actually retrain solov2 for cityscapes dataset. And the  cityscapes annotations have been converted into the coco format using the cityscapesScripts toolbox according the WXinlong/SOLO  in github. The cityscapes.json like that: {"images":[{ "id":0,"width":2048,“height”: ,:"filename": ,"seg_file_name": .............] "categories":["id":1,"name":"person",.............], "annotations":[{"id": 0, "image_id: 0,"segmentation":[[953,406,,,,,,,]],"category_id": ,"iscrwd":,"area" :   ,"bbox":[]}..... And i modifiled the configs and so no. Strangely enough,  it can train normally, but the results are very bad,the AP is only 0.02%. In fact, I checked the Dataloader carefully and found no problem. Can  you  consider adding Cityscapes config file for SOLOv2 training?Thank you very much ! 

------------------ 原始邮件 ------------------ 发件人: "lifuguan/SOLOv2-mmdet" @.>; 发送时间: 2022年3月15日(星期二) 下午5:11 @.>; @.@.>; 主题: Re: [lifuguan/SOLOv2-mmdet] the result is very strange (Issue #1) Results I'm using 2.19.0 exactly, and the results show no GAP between my implementation and the official version. Tips The official checkpoint file should be modified before you use due to the fact that the key names don't match. Code import torch import re dict = torch.load("/disk1/lihao/model_zoo/solo/SOLOv2_R50_1x.pth") patt='mask_feat_head' pattern = re.compile(patt) key_list = list(dict['state_dict'].keys()) for older_val in key_list: if len(pattern.findall(older_val)) != 0: val = re.sub('mask_feat_head', 'mask_head', older_val) dict['state_dict'][val] = dict['state_dict'].pop(older_val) print(dict['state_dict'].keys()) torch.save(dict, '/disk1/lihao/model_zoo/solo/SOLOv2_fpn_R50_1x.pth') Example — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

In general, the model should be fine. Maybe you can load an official checkpoint file, and run a demo.py to find out whether the model can detect targets or not.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants