microsoft / CodeXGLUE

CodeXGLUE
MIT License
1.56k stars 366 forks source link

model file load error #85

Closed mhyeonsoo closed 3 years ago

mhyeonsoo commented 3 years ago

Hello,

I am trying to load the trained model with the test script. When I run with the model.bin path as 'model_name_or_path', it returns the error below.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py", line 557, in get_config_dict
    config_dict = cls._dict_from_json_file(resolved_config_file)
  File "/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py", line 645, in _dict_from_json_file
    text = reader.read()
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 64: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/temp/Defect-detection/code/run.py", line 595, in <module>
    main()
  File "/app/temp/Defect-detection/code/run.py", line 530, in main
    config = config_class.from_pretrained(args.config_name if args.config_name else args.model_name_or_path,
  File "/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py", line 489, in from_pretrained
    config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py", line 578, in get_config_dict
    raise EnvironmentError(msg)
OSError: Couldn't reach server at '/app/temp/Defect-detection/model.bin' to download configuration file or configuration file is not a valid JSON file. Please check network or file content here: /app/temp/Defect-detection/model.bin.

Is there anything else that I need to modify or add?

Thanks,

guoday commented 3 years ago

please follow readme and don't modify --model_name_or_path. If you want to reload model from other path, please modify from

 checkpoint_prefix = 'checkpoint-best-acc/model.bin' 
 output_dir = os.path.join(args.output_dir, '{}'.format(checkpoint_prefix)) 

to

 output_dir = "/app/temp/Defect-detection/model.bin"

here: https://github.com/microsoft/CodeXGLUE/blob/edd66c8f0f62575c65805ffa08c57b419db53743/Code-Code/Defect-detection/code/run.py#L541-L556

mhyeonsoo commented 3 years ago

Thanks, that works for me so far. and it looks be related to the #78 issue which still needs an advice.

Thanks.