dolceTTS / convert_model.py
horiyouta's picture
2502061816
b4409b8
raw
history blame contribute delete
706 Bytes
import torch
from transformers import AutoModel
import os
# Hugging Face Hubからモデルをロード
# `safetensors`形式が自動的にダウンロードされ、PyTorchモデルとしてロードされます。
model = AutoModel.from_pretrained(
"ku-nlp/deberta-v2-large-japanese-char-wwm",
trust_remote_code=True
)
# 変換後のモデルの保存先パス
# `Dockerfile`のRUNコマンドで作成したディレクトリを指定します。
save_path = "bert/deberta-v2-large-japanese-char-wwm/pytorch_model.bin"
# モデルの重みをPyTorch形式で保存
torch.save(model.state_dict(), save_path)
print(f"Model successfully converted and saved to {save_path}")