zsyOAOA / DifFace

DifFace: Blind Face Restoration with Diffused Error Contraction (TPAMI, 2024)
Other
628 stars 42 forks source link

retrain swinIR based on pretrained model, but met ERROR [KeyError: 'state_dict'] #9

Closed zzzzzuber closed 1 year ago

zzzzzuber commented 1 year ago

Number of parameters: 15.79M => Loaded checkpoint /home/zhuchao/code/diface/code/diface/weights/SwinIR/General_Face_ffhq512.pth Traceback (most recent call last): File "main_sr.py", line 32, in trainer = Trainer(configs) File "/home/zhuchao/code/diface/code/diface/trainer.py", line 285, in init super().init(configs) File "/home/zhuchao/code/diface/code/diface/trainer.py", line 67, in init self.resume_from_ckpt() File "/home/zhuchao/code/diface/code/diface/trainer.py", line 145, in resume_from_ckpt util_net.reload_model(self.model, ckpt['state_dict']) KeyError: 'state_dict' I want to finetune swinIR on a small face datasets, but I met this error. It seems the General_Face_ffhq512.pth not save state_dict and iters_start,I don't know how to fix it. Hope you can help me, THANKS!

zsyOAOA commented 1 year ago

@zzzzzuber try: util_net.reload_model(self.model, ckpt).

zzzzzuber commented 1 year ago

I have tried replace "util_net.reload_model(self.model, ckpt['state_dict'])" with "util_net.reload_model(self.model, ckpt)", but i still got some mistake, like "ckpt['iters_start']", "ckpt['log_step']" , "ckpt['log_step'_time]", I don't know these keys mean. Hope you can help me, Thank you!

zsyOAOA commented 1 year ago

The released checkpoint is extracted from ckpt['state_dict']. You can simply change the code to reload the model.

zzzzzuber commented 1 year ago

I will try, thank you for your help! Have a nice day!