Spaces:
Sleeping
Sleeping
File size: 1,453 Bytes
0a78294 |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import argparse
import os
from pathlib import Path
import sys
pwd = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(pwd, "../../"))
import huggingface_hub
from project_settings import project_path
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--repo_id",
default="csukuangfj/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12",
type=str
)
parser.add_argument("--model_filename", default="model.onnx", type=str)
parser.add_argument("--model_sub_folder", default=".", type=str)
parser.add_argument(
"--pretrained_model_dir",
default=(project_path / "pretrained_models").as_posix(),
type=str
)
args = parser.parse_args()
return args
def main():
args = get_args()
pretrained_model_dir = Path(args.pretrained_model_dir)
pretrained_model_dir.mkdir(exist_ok=True)
repo_id: Path = Path(args.repo_id)
local_model_dir = pretrained_model_dir / "huggingface" / repo_id
local_model_dir.mkdir(parents=True, exist_ok=True)
print("download model")
model_filename = huggingface_hub.hf_hub_download(
repo_id=args.repo_id,
filename=args.model_filename,
subfolder=args.model_sub_folder,
local_dir=local_model_dir.as_posix(),
)
print(model_filename)
return
if __name__ == "__main__":
main()
|