PaddleNLP icon indicating copy to clipboard operation
PaddleNLP copied to clipboard

跨模态阅读理解Downloading from https://bj.bcebos.com/paddlenlp/models/community/checkpoints/base_model/model_state.pdparams failed with code 404!

Open ZEIJIERQIANG opened this issue 2 years ago • 7 comments

欢迎您反馈PaddleNLP使用问题,非常感谢您对PaddleNLP的贡献! 在留下您的问题时,辛苦您同步提供如下信息:

  • 版本、环境信息 1)PaddleNLP 2.3.4;paddlepaddle 2.3.1 2)ubuntu,python 3.8.5
  • 我在复现汽车说明书跨模态智能问答项目的时候,在6.1训练模型的时候出现了如下问题
  • [2022-07-27 11:12:10,838] [ INFO] - Already cached /home/idrl/.paddlenlp/models/layoutxlm-base-uncased/sentencepiece.bpe.model [2022-07-27 11:12:11,459] [ INFO] - tokenizer config file saved in /home/idrl/.paddlenlp/models/layoutxlm-base-uncased/tokenizer_config.json [2022-07-27 11:12:11,459] [ INFO] - Special tokens file saved in /home/idrl/.paddlenlp/models/layoutxlm-base-uncased/special_tokens_map.json Init checkpoint from checkpoints/base_model [2022-07-27 11:12:11,460] [ INFO] - Downloading https://bj.bcebos.com/paddlenlp/models/community/checkpoints/base_model/model_state.pdparams and saved to /home/idrl/.paddlenlp/models/checkpoints/base_model [2022-07-27 11:12:11,461] [ INFO] - Downloading model_state.pdparams from https://bj.bcebos.com/paddlenlp/models/community/checkpoints/base_model/model_state.pdparams [2022-07-27 11:12:11,515] [ ERROR] - Downloading from https://bj.bcebos.com/paddlenlp/models/community/checkpoints/base_model/model_state.pdparams failed with code 404! Traceback (most recent call last): File "/home/idrl/anaconda3/lib/python3.8/site-packages/paddlenlp/transformers/model_utils.py", line 272, in from_pretrained resolved_resource_files[file_id] = get_path_from_url( File "/home/idrl/anaconda3/lib/python3.8/site-packages/paddlenlp/utils/downloader.py", line 164, in get_path_from_url fullpath = _download(url, root_dir, md5sum) File "/home/idrl/anaconda3/lib/python3.8/site-packages/paddlenlp/utils/downloader.py", line 200, in _download raise RuntimeError("Downloading from {} failed with code " RuntimeError: Downloading from https://bj.bcebos.com/paddlenlp/models/community/checkpoints/base_model/model_state.pdparams failed with code 404!

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./run_docvqa.py", line 450, in main(args) File "./run_docvqa.py", line 105, in main model = LayoutXLMForTokenClassification_with_CRF.from_pretrained( File "/home/idrl/anaconda3/lib/python3.8/site-packages/paddlenlp/transformers/model_utils.py", line 276, in from_pretrained raise RuntimeError( RuntimeError: Can't load weights for 'checkpoints/base_model'. Please make sure that 'checkpoints/base_model' is:

  • a correct model-identifier of built-in pretrained models,
  • or a correct model-identifier of community-contributed pretrained models,
  • or the correct path to a directory containing relevant modeling files(model_weights and model_config).

ZEIJIERQIANG avatar Jul 27 '22 03:07 ZEIJIERQIANG

可能需要再次确认一下PaddleNLP的版本,需要更新到最新的版本

wawltor avatar Jul 27 '22 04:07 wawltor

使用相对路径的话,改为./checkpoints/base_model试一下。

LemonNoel avatar Jul 27 '22 04:07 LemonNoel

可能需要再次确认一下PaddleNLP的版本,需要更新到最新的版本

paddle-bfloat 0.1.7 paddle2onnx 0.9.8 paddlefsl 1.1.0 paddlenlp 2.3.4 paddleocr 2.5 paddlepaddle-gpu 2.3.1.post112

重新卸载paddlenlp,又装了一次,相对路径也改了,还是一样报错

ZEIJIERQIANG avatar Jul 27 '22 07:07 ZEIJIERQIANG

看起来是当前运行的程序没有正确找到你保存的模型,可以用以下方法排查/修改一下:

  1. 在Extraction下面新建个py文件,在该文件中直接运行导入相关包后,运行以下代码,看是否能功能加载,如果可以,那就是路径的问题,可以进一步排查一下路径问题。LayoutXLMForTokenClassification_with_CRF.from_pretrained("./checkpoints/base_model")
  2. 也可以尝试改动模型保存代码,模型保存时保存model.state_dict, 然后在使用时: a. 新实例化:model=LayoutXLMForTokenClassification_with_CRF, b. 加载保存的state_dict: loaded_dict = paddle.load(state_dict_path) c. 权重赋值:model.set_dict(loaded_dict)

1649759610 avatar Jul 27 '22 08:07 1649759610

你的这个问题,我在公司开发机(不能访问外网)也遇到过,好像是网络的问题,我应该是在虚拟机里面执行才可以的

wshzd avatar Aug 31 '22 07:08 wshzd

版本信息: paddle-bfloat 0.1.7 paddle2onnx 0.9.8 paddlefsl 1.1.0 paddlenlp 2.3.4 paddleocr 2.5 paddlepaddle-gpu 2.3.1

在我doc_vqa目录下面创建了一个python脚本去调用Extraction目录下面的run_docvqa.py的main方法,得到如下结果: 跨模态阅读理解args.init_checkpoint Extraction/checkpoints/layoutxlm/ Traceback (most recent call last): File "run_paddle_server.py", line 180, in layoutxlm_main(layoutxlm_args) File "/xxx/car_manual/doc_vqa/Extraction/run_docvqa.py", line 101, in layoutxlm_main model = LayoutXLMForTokenClassification_with_CRF.from_pretrained( File "/xxx/anaconda3/envs/paddle_car_manual/lib/python3.8/site-packages/paddlenlp/transformers/model_utils.py", line 332, in from_pretrained base_model = cls.base_model_class(*base_args, **base_kwargs) File "/xxx/anaconda3/envs/paddle_car_manual/lib/python3.8/site-packages/paddlenlp/transformers/utils.py", line 96, in impl init_func(self, *args, **kwargs) File "/xxx/anaconda3/envs/paddle_car_manual/lib/python3.8/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 746, in init self.embeddings = LayoutXLMEmbeddings(config) File "/xxx/anaconda3/envs/paddle_car_manual/lib/python3.8/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 142, in init self.register_buffer( File "/xxx/anaconda3/envs/paddle_car_manual/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 767, in register_buffer raise TypeError( TypeError: The registered buffer should be a Paddle.Tensor, but received Variable.

在我doc_vqa目录下面创建了一个test.py脚本,执行是没有问题的,args.init_checkpoint的路径也是Extraction/checkpoints/layoutxlm/ test.py脚本如下: from Extraction.layoutxlm_model import LayoutXLMForTokenClassification_with_CRF

model_name_or_path = "Extraction/checkpoints/layoutxlm/" model = LayoutXLMForTokenClassification_with_CRF.from_pretrained(model_name_or_path) print("model : ", model)

model : LayoutXLMForTokenClassification_with_CRF( (layoutxlm): LayoutXLMModel( (embeddings): LayoutXLMEmbeddings( (word_embeddings): Embedding(250002, 768, padding_idx=0, sparse=False) (position_embeddings): Embedding(514, 768, sparse=False) (x_position_embeddings): Embedding(1024, 128, sparse=False) (y_position_embeddings): Embedding(1024, 128, sparse=False) (h_position_embeddings): Embedding(1024, 128, sparse=False) (w_position_embeddings): Embedding(1024, 128, sparse=False) (token_type_embeddings): Embedding(1, 768, sparse=False) (LayerNorm): LayerNorm(normalized_shape=[768], epsilon=1e-05) (dropout): Dropout(p=0.1, axis=None, mode=upscale_in_train) ) (visual): VisualBackbone( (backbone): FPN(

请问这是什么原因呢?单独创建python脚本执行model = LayoutXLMForTokenClassification_with_CRF.from_pretrained( args.init_checkpoint)是可以的,运行run_test.sh脚本也是可以的,为什么在别的脚本调用却不可以呢?

wshzd avatar Aug 31 '22 07:08 wshzd

是网络问题吗,我当时换了网络也是一样报错,后面就一直没动这个代码

你的这个问题,我在公司开发机(不能访问外网)也遇到过,好像是网络的问题,我应该是在虚拟机里面执行才可以的

BBB-power avatar Sep 07 '22 07:09 BBB-power

This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。

github-actions[bot] avatar Dec 08 '22 02:12 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。

github-actions[bot] avatar Dec 22 '22 16:12 github-actions[bot]