ML_Decoder
ML_Decoder copied to clipboard
when i load model, not found key variable
https://github.com/Alibaba-MIIL/ML_Decoder/blob/8a9e984f671c9c30c98d2c45dfcaf4383381c254/src_files/models/utils/factory.py#L47-L56
when load_head is True, it didn't defined key.
+ i know solution. so, i just notified this problem. plz fix it
Modify the code like this
if 'model' in state:
key = 'model'
else:
key = 'state_dict'
if not load_head:
filtered_dict = {k: v for k, v in state[key].items() if
(k in model.state_dict() and 'head.fc' not in k)}
model.load_state_dict(filtered_dict, strict=False)
else:
model.load_state_dict(state[key], strict=True)
I found the solution in another thread in the issues answered by https://github.com/yangyangtiaoguo