File size: 895 Bytes
bbaeff6 fdf102c bbaeff6 421f96d bbaeff6 1ea7f74 bbaeff6 421f96d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import sys, os
from huggingface_hub import snapshot_download
import ctranslate2
def download_model():
model_id = "JustFrederik/sugoi-v4-ja-en-ct2"
local_folder = snapshot_download(repo_id=model_id, local_dir="./model")
print(f"Files downloaded in: {local_folder}")
def convert_model():
model_dir = "./fairseq_model"
output_dir = "./server/ctranslate2_model"
if (os.path.exists(output_dir) and "-overwrite" not in sys.argv) or not os.path.exists(model_dir): return
print("Converting...")
converter = ctranslate2.converters.FairseqConverter(model_dir)
converter.convert(output_dir) # Você pode escolher entre "int8", "float16" ou deixar como None para não quantizar
print(f"Model converted and saved in: {output_dir}")
if __name__ == "__main__":
if "-download" in sys.argv: download_model()
if "-convert" in sys.argv: convert_model()
|