lifuguan / SOLOv2-mmdet

This project hosts the code for implementing the SOLOv2 algorithms based on the official project(https://github.com/WXinlong/SOLO). Due to the inheritance designation, it enables developers as well as researchers to integrate into our projects more easily and elegantly.
17 stars 1 forks source link

the result is very strange #1

Open pupu-chenyanyan opened 2 years ago

pupu-chenyanyan commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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: @.***>

wptoux commented 2 years ago

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

lifuguan commented 2 years ago

请问为什么要把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 commented 2 years ago

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.