novioleo / FOTS

implement FOTS and apply it on real scenario.
68 stars 23 forks source link

key error #21

Closed yyyash8 closed 4 years ago

yyyash8 commented 4 years ago

I'm getting this error: @novioleo yash@yashpc:~/fots/FOTS$ python3 eval.py -m retrained_model.pth.tar -i images/ -o output/ make: Entering directory '/home/lincode/fots/FOTS/utils/lanms' make: 'adaptor.so' is up to date. make: Leaving directory '/home/lincode/fots/FOTS/utils/lanms' Loading checkpoint: retrained_model.pth.tar ... Traceback (most recent call last): File "eval.py", line 126, in main(args) File "eval.py", line 70, in main model = load_model(model_path, with_gpu) File "eval.py", line 27, in load_model model = FOTSModel(config) File "/home/lincode/fots/FOTS/model/model.py", line 21, in init keys = getattr(common_str, config['model']['keys']) KeyError: 'keys'

novioleo commented 4 years ago

@yyyash8 please checkout common_str.py,and the option is on the bottom of this file.

yyyash8 commented 4 years ago

@yyyash8 please checkout common_str.py,and the option is on the bottom of this file.

but it is already reading keys from utils/common_str.py and I checked it with replacing keys in config.json file i.e. keys="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" but it was still throwing error.

novioleo commented 4 years ago

sorry for my wrong rely,you just need to modify the config.json ,the key option is on the bottom of this file. @yyyash8

novioleo commented 4 years ago

@yyyash8 specify your own key where common_str.py have defined.

sunzhuojun commented 4 years ago

@novioleo I add config['model']['scale'] = 512 tmp = {} tmp['img_h'] = 16 tmp['hidden'] = 1024 config['model']['crnn'] = tmp config['model']['keys'] = 'number_and_dot' config['need_grad_backbone']=True before model = FOTSModel(config) in load_model,but it still has problem below KeyError Traceback (most recent call last)

in ----> 1 model = load_model(model_path, with_gpu) in load_model(model_path, with_gpu) 17 18 model = FOTSModel(config) ---> 19 model.load_state_dict(state_dict) 20 21 if with_gpu: ~/AIDisk/pytorch/github/cv/ocr/FOTS/model/model.py in load_state_dict(self, sd) 86 def load_state_dict(self, sd): 87 for m_ind, m_model in enumerate(self.available_models()): ---> 88 getattr(self, m_model).load_state_dict(sd[f'{m_ind}']) 89 90 @property KeyError: '0'
novioleo commented 4 years ago

@sunzhuojun you didn't save the state dict in specific format.you can post the screenshot of your loaded sd.