facebookresearch / GuidedDistillation

Official implementation of the paper "Guided Distillation for Semi-Supervised Instance Segmentation".
Other
35 stars 4 forks source link

Train semi-supervised model using pretrained checkpoint with error. #9

Open Xinge-Zhou opened 6 months ago

Xinge-Zhou commented 6 months ago

I am using coco dataset and already trained the teacher model , command is python3 -W ignore train_net.py --config-file configs/coco/instance-segmentation/maskformer2_R50_bs16_50ep.yaml --num-gpus 1 --num-machines 1 SSL.PERCENTAGE 250 SSL.TRAIN_SSL False When I Train semi-supervised model using pretrained checkpoint, I got error as bellow.

Traceback (most recent call last):
  File "/home/xiaoyao/code/GuidedDistillation/train_net.py", line 432, in <module>
    launch(
  File "/home/xiaoyao/miniconda3/envs/gd_env/lib/python3.10/site-packages/detectron2/engine/launch.py", line 84, in launch
    main_func(*args)
  File "/home/xiaoyao/code/GuidedDistillation/train_net.py", line 426, in main
    return trainer.train()
  File "/home/xiaoyao/code/GuidedDistillation/modules/defaults.py", line 566, in train
    super().train(self.start_iter, self.max_iter)
  File "/home/xiaoyao/code/GuidedDistillation/modules/train_loop.py", line 164, in train
    self.run_step()
  File "/home/xiaoyao/code/GuidedDistillation/modules/defaults.py", line 576, in run_step
    self._trainer.run_step()
  File "/home/xiaoyao/code/GuidedDistillation/modules/train_loop.py", line 898, in run_step
    if self.model.module.do_ssl and self.model.module.iter % self.model.module.ssl_freq == 0 :
  File "/home/xiaoyao/miniconda3/envs/gd_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1269, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'MaskFormer' object has no attribute 'module'. Did you mean: 'modules'?
roboyul commented 6 months ago

See:

https://github.com/facebookresearch/GuidedDistillation/issues/1#issuecomment-1885186616

Xinge-Zhou commented 6 months ago

See:

#1 (comment)

Thanks for your help, I changed the code, it can running now.

"""
Update teacher model weights.
"""
if self.iter == self.model_teacher.burn_in:
    self.update_teacher_model(ema_decay=0.)
elif self.iter > self.model_teacher.burn_in:
    self.update_teacher_model(ema_decay=self.model_teacher.ema_decay)