[Update] 後方互換性のためのモデルの重みディレクトリ名変更機能を追加

This commit is contained in:
misyaguziya
2026-01-13 15:25:01 +09:00
parent d39d5a198e
commit c257591b21
3 changed files with 34 additions and 21 deletions

View File

@@ -48,22 +48,23 @@ ctranslate2_weights = {
},
}
def backwardCompatibleRenameWeightsDir(root: str):
# 後方互換のためファイル名を変更する
legacy_dirs = {
"m2m100_418M": "m2m100_418M-ct2-int8",
"m2m100_12b": "m2m100_1.2B-ct2-int8",
}
for weight_type_old, weight_type_new in legacy_dirs.items():
path = os_path.join(root, "weights", "ctranslate2", weight_type_new)
old_path = os_path.join(root, "weights", "ctranslate2", weight_type_old)
if os_path.isdir(old_path):
os_rename(old_path, path)
def checkCTranslate2Weight(root: str, weight_type: str = "m2m100_418M-ct2-int8"):
weight_directory_name = ctranslate2_weights[weight_type]["directory_name"]
path = os_path.join(root, "weights", "ctranslate2", weight_directory_name)
# 後方互換のためファイル名を変更する
legacy_dirs = {
"m2m100_418M-ct2-int8": "m2m100_418M",
"m2m100_1.2B-ct2-int8": "m2m100_12b",
}
legacy_dir = legacy_dirs.get(weight_type, None)
if legacy_dir:
old_path = os_path.join(root, "weights", "ctranslate2", legacy_dir)
if os_path.isdir(old_path):
os_rename(old_path, path)
try:
# モデルロード可能かどうかで判定
compute_type = getBestComputeType("cpu", 0)