Closed jjbuck closed 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.
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):
...
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
ormodelTeacher
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 theelse
conditional after line 40 like so (note the modifications toincompatible
andmodel_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?
Errors/warnings when loading from Detectron2 model zoo.