Open zwang123 opened 2 years ago
I do not have this error using the current code on my end.
@yujheli
I have tried a clean clone of the latest version (up to the point of posting the comment) of adaptive teacher and I am still getting the same issue. I strongly suspect if the weights detectron2://ImageNetPretrained/MSRA/R-101.pkl
has been updated such that it is not compatible with the old version of Detectron2==0.3
.
Could you please reinstall a clean version of Detectron2==0.3
(to prevent any modification of codes) as well as re-download the weights by deleting local cache of R-101.pkl
(which, in my case, is located at $HOME/.torch/iopath_cache/detectron2/ImageNetPretrained/MSRA/R-101.pkl
) to re-test the codes?
I do not have this error using the current code on my end.
When I use the weight provided by your interal prod_weights "VOC2Clipart.pth" , the code works .But when I use the weights downlode from the detectron2://ImageNetPretrained/MSRA/R-101.pkl , it makes an error " AttributeError: 'NoneType' object has no attribute 'keys' ",
Why does the R-101.pkl not work? @zwang123 @yujheli
I do not have this error using the current code on my end.
When I use the weight provided by your interal prod_weights "VOC2Clipart.pth" , the code works .But when I use the weights downlode from the detectron2://ImageNetPretrained/MSRA/R-101.pkl , it makes an error " AttributeError: 'NoneType' object has no attribute 'keys' ",
Why does the R-101.pkl not work? @zwang123 @yujheli
yeah, I have the same question.
I found there has something wrong in adaptive_teacher/adapteacher/checkpoint/detection_checkpoint.py
,and I fixed it.
class DetectionTSCheckpointer(DetectionCheckpointer):
def _load_model(self, checkpoint):
if checkpoint.get("__author__", None) == "Caffe2":
# pretrained model weight: only update student model
if checkpoint.get("matching_heuristics", False):
self._convert_ndarray_to_tensor(checkpoint["model"])
# convert weights by name-matching heuristics
model_state_dict = self.model.modelStudent.state_dict()
align_and_update_state_dicts(
model_state_dict,
checkpoint["model"],
c2_conversion=checkpoint.get("__author__", None) == "Caffe2",
)
checkpoint["model"] = model_state_dict
# for non-caffe2 models, use standard ways to load it
incompatible = self._load_student_model(checkpoint)
model_buffers = dict(self.model.modelStudent.named_buffers(recurse=False))
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
else: # whole model
if checkpoint.get("matching_heuristics", False):
self._convert_ndarray_to_tensor(checkpoint["model"])
# convert weights by name-matching heuristics
model_state_dict = self.model.state_dict()
align_and_update_state_dicts(
model_state_dict,
checkpoint["model"],
c2_conversion=checkpoint.get("__author__", None) == "Caffe2",
)
checkpoint["model"] = model_state_dict
# for non-caffe2 models, use standard ways to load it
incompatible = super()._load_model(checkpoint)
model_buffers = dict(self.model.named_buffers(recurse=False))
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
I do not have this error using the current code on my end.
When I use the weight provided by your interal prod_weights "VOC2Clipart.pth" , the code works .But when I use the weights downlode from the detectron2://ImageNetPretrained/MSRA/R-101.pkl , it makes an error " AttributeError: 'NoneType' object has no attribute 'keys' ", Why does the R-101.pkl not work? @zwang123 @yujheli
yeah, I have the same question.
Thank you!It truely work!
I was trying to reproduce the training from PASCAL VOC (source) to Clipart1k (target) using
However, I got the following error message:
I have pinpointed that the issue comes from
detectron2.checkpoint.c2_model_loading.align_and_update_state_dicts
removing all information incheckpoint["model"]
because it is totally normal before entering this function but returnsNone
after the function call in Line 17 of file.../adaptive_teacher/adapteacher/checkpoint/detection_checkpoint.py
.Could you please confirm why this function returns
None
? I really appreciate your help!!As you might have noticed, I am using the following environment: