facebookresearch / unbiased-teacher

PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection
https://arxiv.org/abs/2102.09480
MIT License
409 stars 84 forks source link

How to load weights from Detectron2 model zoo? #38

Closed jjbuck closed 2 years ago

jjbuck commented 2 years ago

I'd like to use the Unbiased Teacher model on a new dataset, and in doing so I'd like to use pre-trained model weights from the analogous Detectron2 model zoo trained on COCO. In other words, I'd like to load the weights from https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_1x/137257794/model_final_b275ba.pkl to jump start the Unbiased Teacher model.

If I try to do this without any modifications, I get a bunch of errors about the incompatibility between the checkpoint and the model state_dict (see below). Upon further inspection, I suppose this is to be expected since the vanilla Faster RCNN model doesn't know anything about the modelStudent or modelTeacher objects, and vice versa.

Am I correct in thinking that the remedy for this is to load the pre-trained weights into both the teacher and student networks? This seems to take place in the DetectionTSCheckpointer class. I could modify the else conditional after line 40 like so (note the modifications to incompatible and model_buffers). However, this would seem to only load the weights into the student network, and I think the appropriate thing to do would be to also load them into the teacher network as well.

Any tips or pointers here?

        else:  # whole model
            print(f'DEBUG: Loading whole model...')
            if checkpoint.get("matching_heuristics", False):
                print('DEBUG: matching heuristics true')
                self._convert_ndarray_to_tensor(checkpoint["model"])
                # convert weights by name-matching heuristics
                checkpoint["model"] = align_and_update_state_dicts(
                    self.model.state_dict(),
                    checkpoint["model"],
                    c2_conversion=checkpoint.get("__author__", None) == "Caffe2",
                )
            # for non-caffe2 models, use standard ways to load it
            incompatible = super()._load_model(checkpoint)
            incompatible = self._load_student_model(checkpoint) # --> Load weights into student?

            model_buffers = dict(self.model.named_buffers(recurse=False))
            model_buffers = dict(self.model.modelStudent.named_buffers(recurse=False)) # --> Load weights into student?
            for k in ["pixel_mean", "pixel_std"]:
                # Ignore missing key message about pixel_mean/std.
                # Though they may be missing in old checkpoints, they will be correctly
                # initialized from config anyway.
                if k in model_buffers:
                    try:
                        incompatible.missing_keys.remove(k)
                    except ValueError:
                        pass
            return incompatible

Errors/warnings when loading from Detectron2 model zoo.

WARNING [08/11 19:08:46 fvcore.common.checkpoint]: Some model parameters or buffers are not found in the checkpoint:
modelStudent.backbone.bottom_up.res2.0.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.0.conv1.weight
modelStudent.backbone.bottom_up.res2.0.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.0.conv2.weight
modelStudent.backbone.bottom_up.res2.0.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.0.conv3.weight
modelStudent.backbone.bottom_up.res2.0.shortcut.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.0.shortcut.weight
modelStudent.backbone.bottom_up.res2.1.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.1.conv1.weight
modelStudent.backbone.bottom_up.res2.1.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.1.conv2.weight
modelStudent.backbone.bottom_up.res2.1.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.1.conv3.weight
modelStudent.backbone.bottom_up.res2.2.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.2.conv1.weight
modelStudent.backbone.bottom_up.res2.2.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.2.conv2.weight
modelStudent.backbone.bottom_up.res2.2.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res2.2.conv3.weight
modelStudent.backbone.bottom_up.res3.0.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.0.conv1.weight
modelStudent.backbone.bottom_up.res3.0.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.0.conv2.weight
modelStudent.backbone.bottom_up.res3.0.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.0.conv3.weight
modelStudent.backbone.bottom_up.res3.0.shortcut.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.0.shortcut.weight
modelStudent.backbone.bottom_up.res3.1.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.1.conv1.weight
modelStudent.backbone.bottom_up.res3.1.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.1.conv2.weight
modelStudent.backbone.bottom_up.res3.1.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.1.conv3.weight
modelStudent.backbone.bottom_up.res3.2.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.2.conv1.weight
modelStudent.backbone.bottom_up.res3.2.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.2.conv2.weight
modelStudent.backbone.bottom_up.res3.2.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.2.conv3.weight
modelStudent.backbone.bottom_up.res3.3.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.3.conv1.weight
modelStudent.backbone.bottom_up.res3.3.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.3.conv2.weight
modelStudent.backbone.bottom_up.res3.3.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res3.3.conv3.weight
modelStudent.backbone.bottom_up.res4.0.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.0.conv1.weight
modelStudent.backbone.bottom_up.res4.0.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.0.conv2.weight
modelStudent.backbone.bottom_up.res4.0.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.0.conv3.weight
modelStudent.backbone.bottom_up.res4.0.shortcut.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.0.shortcut.weight
modelStudent.backbone.bottom_up.res4.1.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.1.conv1.weight
modelStudent.backbone.bottom_up.res4.1.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.1.conv2.weight
modelStudent.backbone.bottom_up.res4.1.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.1.conv3.weight
modelStudent.backbone.bottom_up.res4.2.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.2.conv1.weight
modelStudent.backbone.bottom_up.res4.2.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.2.conv2.weight
modelStudent.backbone.bottom_up.res4.2.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.2.conv3.weight
modelStudent.backbone.bottom_up.res4.3.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.3.conv1.weight
modelStudent.backbone.bottom_up.res4.3.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.3.conv2.weight
modelStudent.backbone.bottom_up.res4.3.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.3.conv3.weight
modelStudent.backbone.bottom_up.res4.4.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.4.conv1.weight
modelStudent.backbone.bottom_up.res4.4.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.4.conv2.weight
modelStudent.backbone.bottom_up.res4.4.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.4.conv3.weight
modelStudent.backbone.bottom_up.res4.5.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.5.conv1.weight
modelStudent.backbone.bottom_up.res4.5.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.5.conv2.weight
modelStudent.backbone.bottom_up.res4.5.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res4.5.conv3.weight
modelStudent.backbone.bottom_up.res5.0.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.0.conv1.weight
modelStudent.backbone.bottom_up.res5.0.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.0.conv2.weight
modelStudent.backbone.bottom_up.res5.0.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.0.conv3.weight
modelStudent.backbone.bottom_up.res5.0.shortcut.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.0.shortcut.weight
modelStudent.backbone.bottom_up.res5.1.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.1.conv1.weight
modelStudent.backbone.bottom_up.res5.1.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.1.conv2.weight
modelStudent.backbone.bottom_up.res5.1.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.1.conv3.weight
modelStudent.backbone.bottom_up.res5.2.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.2.conv1.weight
modelStudent.backbone.bottom_up.res5.2.conv2.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.2.conv2.weight
modelStudent.backbone.bottom_up.res5.2.conv3.norm.{bias, weight}
modelStudent.backbone.bottom_up.res5.2.conv3.weight
modelStudent.backbone.bottom_up.stem.conv1.norm.{bias, weight}
modelStudent.backbone.bottom_up.stem.conv1.weight
modelStudent.backbone.fpn_lateral2.{bias, weight}
modelStudent.backbone.fpn_lateral3.{bias, weight}
modelStudent.backbone.fpn_lateral4.{bias, weight}
modelStudent.backbone.fpn_lateral5.{bias, weight}
modelStudent.backbone.fpn_output2.{bias, weight}
modelStudent.backbone.fpn_output3.{bias, weight}
modelStudent.backbone.fpn_output4.{bias, weight}
modelStudent.backbone.fpn_output5.{bias, weight}
modelStudent.proposal_generator.rpn_head.anchor_deltas.{bias, weight}
modelStudent.proposal_generator.rpn_head.conv.{bias, weight}
modelStudent.proposal_generator.rpn_head.objectness_logits.{bias, weight}
modelStudent.roi_heads.box_head.fc1.{bias, weight}
modelStudent.roi_heads.box_head.fc2.{bias, weight}
modelStudent.roi_heads.box_predictor.bbox_pred.{bias, weight}
modelStudent.roi_heads.box_predictor.cls_score.{bias, weight}
modelTeacher.backbone.bottom_up.res2.0.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.0.conv1.weight
modelTeacher.backbone.bottom_up.res2.0.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.0.conv2.weight
modelTeacher.backbone.bottom_up.res2.0.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.0.conv3.weight
modelTeacher.backbone.bottom_up.res2.0.shortcut.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.0.shortcut.weight
modelTeacher.backbone.bottom_up.res2.1.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.1.conv1.weight
modelTeacher.backbone.bottom_up.res2.1.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.1.conv2.weight
modelTeacher.backbone.bottom_up.res2.1.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.1.conv3.weight
modelTeacher.backbone.bottom_up.res2.2.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.2.conv1.weight
modelTeacher.backbone.bottom_up.res2.2.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.2.conv2.weight
modelTeacher.backbone.bottom_up.res2.2.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res2.2.conv3.weight
modelTeacher.backbone.bottom_up.res3.0.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.0.conv1.weight
modelTeacher.backbone.bottom_up.res3.0.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.0.conv2.weight
modelTeacher.backbone.bottom_up.res3.0.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.0.conv3.weight
modelTeacher.backbone.bottom_up.res3.0.shortcut.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.0.shortcut.weight
modelTeacher.backbone.bottom_up.res3.1.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.1.conv1.weight
modelTeacher.backbone.bottom_up.res3.1.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.1.conv2.weight
modelTeacher.backbone.bottom_up.res3.1.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.1.conv3.weight
modelTeacher.backbone.bottom_up.res3.2.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.2.conv1.weight
modelTeacher.backbone.bottom_up.res3.2.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.2.conv2.weight
modelTeacher.backbone.bottom_up.res3.2.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.2.conv3.weight
modelTeacher.backbone.bottom_up.res3.3.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.3.conv1.weight
modelTeacher.backbone.bottom_up.res3.3.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.3.conv2.weight
modelTeacher.backbone.bottom_up.res3.3.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res3.3.conv3.weight
modelTeacher.backbone.bottom_up.res4.0.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.0.conv1.weight
modelTeacher.backbone.bottom_up.res4.0.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.0.conv2.weight
modelTeacher.backbone.bottom_up.res4.0.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.0.conv3.weight
modelTeacher.backbone.bottom_up.res4.0.shortcut.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.0.shortcut.weight
modelTeacher.backbone.bottom_up.res4.1.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.1.conv1.weight
modelTeacher.backbone.bottom_up.res4.1.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.1.conv2.weight
modelTeacher.backbone.bottom_up.res4.1.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.1.conv3.weight
modelTeacher.backbone.bottom_up.res4.2.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.2.conv1.weight
modelTeacher.backbone.bottom_up.res4.2.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.2.conv2.weight
modelTeacher.backbone.bottom_up.res4.2.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.2.conv3.weight
modelTeacher.backbone.bottom_up.res4.3.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.3.conv1.weight
modelTeacher.backbone.bottom_up.res4.3.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.3.conv2.weight
modelTeacher.backbone.bottom_up.res4.3.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.3.conv3.weight
modelTeacher.backbone.bottom_up.res4.4.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.4.conv1.weight
modelTeacher.backbone.bottom_up.res4.4.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.4.conv2.weight
modelTeacher.backbone.bottom_up.res4.4.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.4.conv3.weight
modelTeacher.backbone.bottom_up.res4.5.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.5.conv1.weight
modelTeacher.backbone.bottom_up.res4.5.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.5.conv2.weight
modelTeacher.backbone.bottom_up.res4.5.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res4.5.conv3.weight
modelTeacher.backbone.bottom_up.res5.0.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.0.conv1.weight
modelTeacher.backbone.bottom_up.res5.0.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.0.conv2.weight
modelTeacher.backbone.bottom_up.res5.0.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.0.conv3.weight
modelTeacher.backbone.bottom_up.res5.0.shortcut.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.0.shortcut.weight
modelTeacher.backbone.bottom_up.res5.1.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.1.conv1.weight
modelTeacher.backbone.bottom_up.res5.1.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.1.conv2.weight
modelTeacher.backbone.bottom_up.res5.1.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.1.conv3.weight
modelTeacher.backbone.bottom_up.res5.2.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.2.conv1.weight
modelTeacher.backbone.bottom_up.res5.2.conv2.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.2.conv2.weight
modelTeacher.backbone.bottom_up.res5.2.conv3.norm.{bias, weight}
modelTeacher.backbone.bottom_up.res5.2.conv3.weight
modelTeacher.backbone.bottom_up.stem.conv1.norm.{bias, weight}
modelTeacher.backbone.bottom_up.stem.conv1.weight
modelTeacher.backbone.fpn_lateral2.{bias, weight}
modelTeacher.backbone.fpn_lateral3.{bias, weight}
modelTeacher.backbone.fpn_lateral4.{bias, weight}
modelTeacher.backbone.fpn_lateral5.{bias, weight}
modelTeacher.backbone.fpn_output2.{bias, weight}
modelTeacher.backbone.fpn_output3.{bias, weight}
modelTeacher.backbone.fpn_output4.{bias, weight}
modelTeacher.backbone.fpn_output5.{bias, weight}
modelTeacher.proposal_generator.rpn_head.anchor_deltas.{bias, weight}
modelTeacher.proposal_generator.rpn_head.conv.{bias, weight}
modelTeacher.proposal_generator.rpn_head.objectness_logits.{bias, weight}
modelTeacher.roi_heads.box_head.fc1.{bias, weight}
modelTeacher.roi_heads.box_head.fc2.{bias, weight}
modelTeacher.roi_heads.box_predictor.bbox_pred.{bias, weight}
modelTeacher.roi_heads.box_predictor.cls_score.{bias, weight}
WARNING [08/11 19:08:46 fvcore.common.checkpoint]: The checkpoint state_dict contains keys that are not used by the model:
  backbone.fpn_lateral2.{bias, weight}
  backbone.fpn_output2.{bias, weight}
  backbone.fpn_lateral3.{bias, weight}
  backbone.fpn_output3.{bias, weight}
  backbone.fpn_lateral4.{bias, weight}
  backbone.fpn_output4.{bias, weight}
  backbone.fpn_lateral5.{bias, weight}
  backbone.fpn_output5.{bias, weight}
  backbone.bottom_up.stem.conv1.weight
  backbone.bottom_up.stem.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.shortcut.weight
  backbone.bottom_up.res2.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.conv1.weight
  backbone.bottom_up.res2.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.conv2.weight
  backbone.bottom_up.res2.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.0.conv3.weight
  backbone.bottom_up.res2.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.1.conv1.weight
  backbone.bottom_up.res2.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.1.conv2.weight
  backbone.bottom_up.res2.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.1.conv3.weight
  backbone.bottom_up.res2.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.2.conv1.weight
  backbone.bottom_up.res2.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.2.conv2.weight
  backbone.bottom_up.res2.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res2.2.conv3.weight
  backbone.bottom_up.res2.2.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.shortcut.weight
  backbone.bottom_up.res3.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.conv1.weight
  backbone.bottom_up.res3.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.conv2.weight
  backbone.bottom_up.res3.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.0.conv3.weight
  backbone.bottom_up.res3.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.1.conv1.weight
  backbone.bottom_up.res3.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.1.conv2.weight
  backbone.bottom_up.res3.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.1.conv3.weight
  backbone.bottom_up.res3.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.2.conv1.weight
  backbone.bottom_up.res3.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.2.conv2.weight
  backbone.bottom_up.res3.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.2.conv3.weight
  backbone.bottom_up.res3.2.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.3.conv1.weight
  backbone.bottom_up.res3.3.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.3.conv2.weight
  backbone.bottom_up.res3.3.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res3.3.conv3.weight
  backbone.bottom_up.res3.3.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.shortcut.weight
  backbone.bottom_up.res4.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.conv1.weight
  backbone.bottom_up.res4.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.conv2.weight
  backbone.bottom_up.res4.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.0.conv3.weight
  backbone.bottom_up.res4.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.1.conv1.weight
  backbone.bottom_up.res4.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.1.conv2.weight
  backbone.bottom_up.res4.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.1.conv3.weight
  backbone.bottom_up.res4.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.2.conv1.weight
  backbone.bottom_up.res4.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.2.conv2.weight
  backbone.bottom_up.res4.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.2.conv3.weight
  backbone.bottom_up.res4.2.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.3.conv1.weight
  backbone.bottom_up.res4.3.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.3.conv2.weight
  backbone.bottom_up.res4.3.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.3.conv3.weight
  backbone.bottom_up.res4.3.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.4.conv1.weight
  backbone.bottom_up.res4.4.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.4.conv2.weight
  backbone.bottom_up.res4.4.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.4.conv3.weight
  backbone.bottom_up.res4.4.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.5.conv1.weight
  backbone.bottom_up.res4.5.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.5.conv2.weight
  backbone.bottom_up.res4.5.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res4.5.conv3.weight
  backbone.bottom_up.res4.5.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.shortcut.weight
  backbone.bottom_up.res5.0.shortcut.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.conv1.weight
  backbone.bottom_up.res5.0.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.conv2.weight
  backbone.bottom_up.res5.0.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.0.conv3.weight
  backbone.bottom_up.res5.0.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.1.conv1.weight
  backbone.bottom_up.res5.1.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.1.conv2.weight
  backbone.bottom_up.res5.1.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.1.conv3.weight
  backbone.bottom_up.res5.1.conv3.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.2.conv1.weight
  backbone.bottom_up.res5.2.conv1.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.2.conv2.weight
  backbone.bottom_up.res5.2.conv2.norm.{bias, running_mean, running_var, weight}
  backbone.bottom_up.res5.2.conv3.weight
  backbone.bottom_up.res5.2.conv3.norm.{bias, running_mean, running_var, weight}
  proposal_generator.anchor_generator.cell_anchors.{0, 1, 2, 3, 4}
  proposal_generator.rpn_head.conv.{bias, weight}
  proposal_generator.rpn_head.objectness_logits.{bias, weight}
  proposal_generator.rpn_head.anchor_deltas.{bias, weight}
  roi_heads.box_head.fc1.{bias, weight}
  roi_heads.box_head.fc2.{bias, weight}
  roi_heads.box_predictor.cls_score.{bias, weight}
  roi_heads.box_predictor.bbox_pred.{bias, weight}
ycliu93 commented 2 years ago

Thanks for pointing this out!

Our model writing/loading is based on DetectionTSCheckpointer, which combines both the Student and Teacher models.

I renamed the model to modeStudent and modelTeacher to prevent the loading/writing overlapped, and that is the reason why you will get the error when you try to load the pre-trained model.

As you seem to have successfully loaded the Student model with the pretrained object detector, you could just copy the student model weight (which is the pre-trained model) to modelTeacher as we did at the beginning of the mutual learning stage.

https://github.com/facebookresearch/unbiased-teacher/blob/6977c6f77c812fae4064dc1b3865658c2ed247b1/ubteacher/engine/trainer.py#L504

Divadi commented 2 years ago

I ran into a similar error previously, and I was able to resolve it by modifying the top:

class DetectionTSCheckpointer(DetectionCheckpointer):
    def _load_model(self, checkpoint):
        if checkpoint.get("__author__", None) == "Caffe2" or \
            checkpoint.get("__author__", None) == "Detectron2 Model Zoo":
            # pretrained model weight: only update student model
            if checkpoint.get("matching_heuristics", False):
...