HikariTJU / LD

Localization Distillation for Object Detection (CVPR 2022, TPAMI 2023)
Apache License 2.0
355 stars 51 forks source link

AttributeError: 'ATSSAssigner' object has no attribute 'assign_neg' #18

Closed zkchen95 closed 2 years ago

zkchen95 commented 2 years ago

https://github.com/HikariTJU/LD/blob/3c5e398e3526c6ee973fa30cf056e846315408cf/mmdet/models/dense_heads/ld_atss.py#L467

您好,我使用了配置文件:configs/ld/ld_r50_atss_r101_1x.py 其中,bbox_head的type为LDATSSHead train_cfg 的 assigner 为 ATSSAssigner 但是我发现,在mmdet/models/dense_heads/ld_atss.py第467行的assign_neg函数,并没有定义。

也就是说:LD/mmdet/core/bbox/assigners/atss_assigner.py的class ATSSAssigner 里没有assign_neg函数

HikariTJU commented 2 years ago

改成get_vlr_region

zkchen95 commented 2 years ago

改成get_vlr_region

我看到您更改了,但是我看该函数的return只有一个结果,但是要获得的有两个变量assign_result_neg, assigned_neg。 报错信息:ValueError: too many values to unpack (expected 2)

HikariTJU commented 2 years ago

删掉前面的

zkchen95 commented 2 years ago

删掉前面的

您好,您是指删掉assign_result_neg吗?但是随后的sample函数有调用该变量,不知道是否要跟着变动?

zkchen95 commented 2 years ago

您好,删掉之后,这边报错了AttributeError: 'Tensor' object has no attribute 'gt_inds' 应该是您的return 类型有问题,您可以帮忙改一下吗?

HikariTJU commented 2 years ago

修好了

zkchen95 commented 2 years ago

您好,再次打扰您! 在ld_atss.py的loss_single函数的soft_target的reshape因形状不匹配报错: shape '[-1, 68]' is invalid for input of size 141056

https://github.com/HikariTJU/LD/blob/07b62529b30d231b8312d2e045fe0676fa7aca19/mmdet/models/dense_heads/ld_atss.py#L79

zkchen95 commented 2 years ago

您好,再次打扰您! 在ld_atss.py的loss_single函数的soft_target的reshape因形状不匹配报错: shape '[-1, 68]' is invalid for input of size 141056

https://github.com/HikariTJU/LD/blob/07b62529b30d231b8312d2e045fe0676fa7aca19/mmdet/models/dense_heads/ld_atss.py#L79

reg_max默认为16,不是很理解该参数,要如何设置reg_max呢?

HikariTJU commented 2 years ago
  1. 你需要先训一个general distribution版本的atss r101才能训ld
  2. reg_max参考gfocal里的n image
  3. 顺便问一句,为什么不用gfl, 而是用atss?
Logicino commented 2 years ago
  1. 你需要先训一个general distribution版本的atss r101才能训ld

    1. reg_max参考gfocal里的n image

    2. 顺便问一句,为什么不用gfl, 而是用atss?

hello作者,想请问一下想要修改ld的teacher网络 例如使用faster RCNN作为teacher网络 我把teacher config改为了faster RCNN的位置 将pth改为了自己训练好的权重

    type='KnowledgeDistillationSingleStageDetector',
    # teacher_config='configs/gfl/gfl_r101_fpn_mstrain_2x_coco.py',
    teacher_config='configs/my_configs/faster_rcnn_r50_fpn_1x_coco.py',
    # teacher_ckpt=
    # 'https://download.openmmlab.com/mmdetection/v2.0/gfl/gfl_r101_fpn_mstrain_2x_coco/gfl_r101_fpn_mstrain_2x_coco_20200629_200126-dd12f847.pth',
    teacher_ckpt=
    '/home/a/mmdetection/work_dirs/faster_rcnn_r50_fpn_1x_coco/epoch_12.pth',

这样训练时提示: AttributeError: 'FasterRCNN' object has no attribute 'bbox_head' 我理解是因为 bbox_head=dict( type='LDHead', ... 这里检测头类别的问题 但是我不知道应该根据什么修改呢? 我试着随便改成了RPNHead 就会提示报错 TypeError: KnowledgeDistillationSingleStageDetector: RPNHead: init() got multiple values for argument 'num_classes' 想请问作者bbox_head的type应该如何确定呢?以及有无可以参考的资料呢,谢谢!

HikariTJU commented 2 years ago

@Logicino 目前ld只能用在densehead上,实际上我只实现了atss,gfl,fcos,retina,改成别的都是不行的,建议教师网络和学生用一样的detector

Logicino commented 2 years ago

@Logicino 目前ld只能用在densehead上,实际上我只实现了atss,gfl,fcos,retina,改成别的都是不行的,建议教师网络和学生用一样的detector

遇到'ATSSGFLHead is not in the models registry'的问题 我重新对比了您的LD工程和官方的mmdetection中的ld网络 LD工程中会更多一些网络结构 之前我成功训练了mmdetection中的ld网络 ld_r18_gflv1_r101_fpn_coco_1x.py 这个用的是LDHead 于是想试下LD工程中的其他网络 ld_r50_atss_r101_1x.py 我先训练它的teacher网络 atss_gfl_r101_2x.py 但是遇到了ATSSGFLHead is not in the models registry的问题 我查看了mmdet/models/中的dense_head有atss_gfl_head的文件

图片

我想是不是因为我用的还是原来的mmdetection的环境跑的呢 没有用新的环境重新编译 ld的能用是因为mmdetection官方工程中也有ld_head... 0-0

HikariTJU commented 2 years ago

@Logicino 你都把答案说出来了

zkchen95 commented 2 years ago

mmdet路径没有更新过来,应该在新的路径下用pip install -e .

---Original--- From: @.> Date: Tue, Dec 14, 2021 21:13 PM To: @.>; Cc: @.**@.>; Subject: Re: [HikariTJU/LD] AttributeError: 'ATSSAssigner' object has noattribute 'assign_neg' (Issue #18)

@Logicino 目前ld只能用在densehead上,实际上我只实现了atss,gfl,fcos,retina,改成别的都是不行的,建议教师网络和学生用一样的detector

遇到'ATSSGFLHead is not in the models registry'的问题 我重新对比了您的LD工程和官方的mmdetection中的ld网络 LD工程中会更多一些网络结构 之前我成功训练了mmdetection中的ld网络 ld_r18_gflv1_r101_fpn_coco_1x.py 这个用的是LDHead 于是想试下LD工程中的其他网络 ld_r50_atss_r101_1x.py 我先训练它的teacher网络 atss_gfl_r101_2x.py 但是遇到了ATSSGFLHead is not in the models registry的问题 我查看了mmdet/models/中的dense_head有atss_gfl_head的文件

我想是不是因为我用的还是原来的mmdetection的环境跑的呢 没有用新的环境重新编译 ld的能用是因为mmdetection官方工程中也有ld_head... 0-0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Logicino commented 2 years ago

@Logicino 你都把答案说出来了

我又重新按说明版本装了一个虚拟环境,已解决hhh感谢~

Logicino commented 2 years ago

mmdet路径没有更新过来,应该在新的路径下用pip install -e . ---Original--- From: @.> Date: Tue, Dec 14, 2021 21:13 PM To: @.>; Cc: @.**@.>; Subject: Re: [HikariTJU/LD] AttributeError: 'ATSSAssigner' object has noattribute 'assign_neg' (Issue #18) @Logicino 目前ld只能用在densehead上,实际上我只实现了atss,gfl,fcos,retina,改成别的都是不行的,建议教师网络和学生用一样的detector 遇到'ATSSGFLHead is not in the models registry'的问题 我重新对比了您的LD工程和官方的mmdetection中的ld网络 LD工程中会更多一些网络结构 之前我成功训练了mmdetection中的ld网络 ld_r18_gflv1_r101_fpn_coco_1x.py 这个用的是LDHead 于是想试下LD工程中的其他网络 ld_r50_atss_r101_1x.py 我先训练它的teacher网络 atss_gfl_r101_2x.py 但是遇到了ATSSGFLHead is not in the models registry的问题 我查看了mmdet/models/中的dense_head有atss_gfl_head的文件 我想是不是因为我用的还是原来的mmdetection的环境跑的呢 没有用新的环境重新编译 ld的能用是因为mmdetection官方工程中也有ld_head... 0-0 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

已解决,感谢~

Logicino commented 2 years ago

mmdet路径没有更新过来,应该在新的路径下用pip install -e . ---Original--- From: @.> Date: Tue, Dec 14, 2021 21:13 PM To: @.>; Cc: @.**@.>; Subject: Re: [HikariTJU/LD] AttributeError: 'ATSSAssigner' object has noattribute 'assign_neg' (Issue #18) @Logicino 目前ld只能用在densehead上,实际上我只实现了atss,gfl,fcos,retina,改成别的都是不行的,建议教师网络和学生用一样的detector 遇到'ATSSGFLHead is not in the models registry'的问题 我重新对比了您的LD工程和官方的mmdetection中的ld网络 LD工程中会更多一些网络结构 之前我成功训练了mmdetection中的ld网络 ld_r18_gflv1_r101_fpn_coco_1x.py 这个用的是LDHead 于是想试下LD工程中的其他网络 ld_r50_atss_r101_1x.py 我先训练它的teacher网络 atss_gfl_r101_2x.py 但是遇到了ATSSGFLHead is not in the models registry的问题 我查看了mmdet/models/中的dense_head有atss_gfl_head的文件 我想是不是因为我用的还是原来的mmdetection的环境跑的呢 没有用新的环境重新编译 ld的能用是因为mmdetection官方工程中也有ld_head... 0-0 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

您好,我想问下您运行起来用的是CUDA10.1吗? 我系统安装的是CUDA10.2 我理解为 是不是因为这个工程是基于mmdetection的历史版本写的 所以要求pytorch的版本和mmcv-full的版本业需要是历史版本 我按照install.md中的安装方法和版本要求,分别使用了CUDA10.1和10.2的pytorch两个环境 按照这个编译以后,项目中的网络能训练第一个epoch,但是在第一个save checkpoints的地方会遇到 IndexError: list index out of range的问题,两个环境都是一样的 我尝试了其他的网络,例如单纯去训练一个faster rcnn这样的网络,也会遇到 IndexError 我看网上有一些解决方法,例如调整learning rate, num_classes修改(已经修改,但是我训练的只有一类,不知道是否是这个原因?)也还是同样的报错 不知是不是因为这个必须使用CUDA10.1版本呢,谢谢

HikariTJU commented 2 years ago

@Logicino CUDA版本不对不会报这种错,应该跟你训练的只有一类有关

Logicino commented 2 years ago

@Logicino CUDA版本不对不会报这种错,应该跟你训练的只有一类有关

orz我觉得我可能还是和这个版本项目八字不合(x) 试了在新版本git clone下来的mmdetection项目中集成的是可以跑的(包括改类别,mmdetection中集成的LD,单纯训练mmdetection中的atss等),但是LD项目里的各种模型都不行 我试着把LD里有但mmdetection里没有的文件,例如atss和fcos,以及对应的head文件也贴到mmdetection中,但会报没有registry的错误 例如atss会报错: KeyError: "KnowledgeDistillationSingleStageDetector: 'LDATSSHead is not in the models registry'" 感觉应该是缺少在某个注册文件中修改head的注册,单纯复制还是不行 然后fcos的话会报错: TypeError: KnowledgeDistillationSingleStageDetector: FPN: init() got an unexpected keyword argument 'extra_convs_on_inputs' 感觉这个代码还是只能在老版本的情况下用(mmcv=1.2.7)库这些都是按老版本的写的qwq

HikariTJU commented 2 years ago

@Logicino 你发下 IndexError的详细报错看看

Logicino commented 2 years ago

@Logicino 你发下 IndexError的详细报错看看

最终还是没用这个版本里的,用了新版mmdetection里的做了尝试qwq gfl看来和作者的实验结果基本是相同的 我试了两种不太相同的数据集的,在同一个数据集上提升比较大 因为我只有8G显存最大只能训练ResNet50,但是T+attention+DCN我试了是有一点提升的(x) 然后不同数据集的师生会有反作用,和干涉学到的分布相符合,合理 总之,非常感谢作者之前提供的帮助和解答!!!~(鞠躬)