当前位置:   article > 正文

预训练模型tensorflow版本转pytorch_stabilityai/sd-vae-ft-mse does not appear to have

stabilityai/sd-vae-ft-mse does not appear to have a file named config.json.

背景

huggingface 下载的模型大多是 tensorflow 版本的,错误的使用会报错:Error no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory /home/nuo/pretrained_models/chinese_bert_wwm_L-12_H-768_A-12.

安装 pytorch-transformers

pip install pytorch-transformers

生成 pytorch.bin

  1. cd ~/Softwares/anaconda3/envs/pytorchenv/lib/python3.8/site-packages/pytorch_transformers
  2. export b=/home/pretrained_models/chinese_bert_wwm_L-12_H-768_A-12
  3. python convert_tf_checkpoint_to_pytorch.py --tf_checkpoint_path="$b/bert_model.ckpt" --bert_config_file="$b/bert_config.json" --pytorch_dump_path="$b/pytorch_model.bin"

期间可能报错没有tensorflow包之类的。就缺啥安啥。

效果

Save PyTorch model to /home/nuo/pretrained_models/chinese_bert_wwm_L-12_H-768_A-12/pytorch_model.bin

does not appear to have a file named config.json.

原始下载的文件里,json 文件名叫做 bert_config.json!不可以,要改成 config.json!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/360763
推荐阅读
相关标签
  

闽ICP备14008679号