-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bookbot-hive/g2p
Implemented G2p
- Loading branch information
Showing
28 changed files
with
20,583 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pathlib import Path | ||
import argparse | ||
import shutil | ||
|
||
from optimum.onnxruntime import ORTModelForSeq2SeqLM | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument( | ||
"--model_name", type=str, required=True, help="HuggingFace Hub model name." | ||
) | ||
parser.add_argument( | ||
"--hub_model_id", type=str, required=True, help="HuggingFace Hub model ID for pushing" | ||
) | ||
return parser.parse_args() | ||
|
||
def main(args): | ||
if "/" in args.model_name: | ||
_, model_name = args.model_name.split("/") | ||
else: | ||
model_name = args.model_name | ||
|
||
save_dir = Path(f"onnx-{model_name}") | ||
|
||
ort_model = ORTModelForSeq2SeqLM.from_pretrained(args.model_name, export=True) | ||
ort_model.save_pretrained(save_dir) | ||
|
||
ort_model.push_to_hub(str(save_dir), repository_id=args.hub_model_id) | ||
|
||
# remove local repository after finish | ||
shutil.rmtree(save_dir) | ||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
main(args) |
Oops, something went wrong.