ConsistentTeacher icon indicating copy to clipboard operation
ConsistentTeacher copied to clipboard

AttributeError: ConsistentTeacher: 'NoneType' object has no attribute 'num_scores'

Open FLYDust1101 opened this issue 9 months ago • 2 comments

I have 1 GPU,and i run the code for 4000iters.

Before testing, I copyed DynamicSoftLabelAssigner to ConsistentTeacher-main\thirdparty\mmdetection\mmdet\core\bbox\assigners and change init.py

from .dynamic_assigner import DynamicSoftLabelAssigner

__all__ = [
    'BaseAssigner', 'MaxIoUAssigner', 'ApproxMaxIoUAssigner', 'AssignResult',
    'PointAssigner', 'ATSSAssigner', 'CenterRegionAssigner', 'GridAssigner',
    'HungarianAssigner', 'RegionAssigner', 'UniformAssigner', 'SimOTAAssigner',
    'TaskAlignedAssigner', 'MaskHungarianAssigner', 'DynamicSoftLabelAssigner'
]

It seems worked with following code.

from mmdet.core.bbox.builder import BBOX_ASSIGNERS
print(BBOX_ASSIGNERS)

But it still have following error when testing. Should I register Class ConsistentTeacher and class FAM3D and... like DynamicSoftLabelAssigner???

loading annotations into memory...
Done (t=0.73s)
creating index...
index created!
Traceback (most recent call last):
  File "C:\Anaconda3\envs\ct\lib\site-packages\mmcv\utils\registry.py", line 52, in build_from_cfg               
    return obj_cls(**args)                                                                                       
  File "d:\lyb\consistentteacher-main\ssod\models\consistent_teacher.py", line 33, in __init__                   
    num_scores = self.train_cfg.num_scores                                                                       
AttributeError: 'NoneType' object has no attribute 'num_scores'                                                  
                                                                                                                 
During handling of the above exception, another exception occurred:                                              
                                                                                                                 
Traceback (most recent call last):                                                                               
  File "tools/test.py", line 261, in <module>                                                                    
    main()                                                                                                       
  File "tools/test.py", line 204, in main                                                                        
    model = build_detector(cfg.model, test_cfg=cfg.get("test_cfg"))                                              
  File "d:\lyb\consistentteacher-main\thirdparty\mmdetection\mmdet\models\builder.py", line 58, in build_detector
    return DETECTORS.build(
  File "C:\Anaconda3\envs\ct\lib\site-packages\mmcv\utils\registry.py", line 212, in build
    return self.build_func(*args, **kwargs, registry=self)
  File "C:\Anaconda3\envs\ct\lib\site-packages\mmcv\cnn\builder.py", line 27, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "C:\Anaconda3\envs\ct\lib\site-packages\mmcv\utils\registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
AttributeError: ConsistentTeacher: 'NoneType' object has no attribute 'num_scores'

FLYDust1101 avatar Apr 28 '24 12:04 FLYDust1101

I run in the terminal

python tools/test.py configs\consistent-teacher\consistent_teacher_r50_fpn_coco_180k_10p.py\
work_dirs\consistent_teacher_r50_fpn_coco_180k_10p\iter_4000.pth\
--eval bbox
ConsistentTeacher-main
--ssod
----apis
----core
----datasets
----.....
--configs\consistent_teacher\...
--thirdparty
----mmdetection/mmdet/core/bbox/assigners
--------dyramic_assigner.py(add)
--work_dirs\consistent_teacher_r50_fpn_coco_180k_10p\...

FLYDust1101 avatar Apr 28 '24 12:04 FLYDust1101

请问您解决这个问题了吗,我遇到了同样的问题

MrDec avatar Jul 11 '24 02:07 MrDec

https://github.com/Adamdad/ConsistentTeacher/issues/15 this issue solved the problem

heha102 avatar Oct 16 '24 13:10 heha102