hatch fmt
This commit is contained in:
@@ -31,8 +31,8 @@ if __name__ == "__main__":
|
|||||||
# モデルの入出力先ファイルパスを取得
|
# モデルの入出力先ファイルパスを取得
|
||||||
language = Languages(args.language)
|
language = Languages(args.language)
|
||||||
pretrained_model_name_or_path = DEFAULT_BERT_MODEL_PATHS[language]
|
pretrained_model_name_or_path = DEFAULT_BERT_MODEL_PATHS[language]
|
||||||
onnx_temp_model_path = Path(pretrained_model_name_or_path) / f"model_temp.onnx"
|
onnx_temp_model_path = Path(pretrained_model_name_or_path) / "model_temp.onnx"
|
||||||
onnx_optimized_model_path = Path(pretrained_model_name_or_path) / f"model.onnx"
|
onnx_optimized_model_path = Path(pretrained_model_name_or_path) / "model.onnx"
|
||||||
tokenizer_json_path = Path(pretrained_model_name_or_path) / "tokenizer.json"
|
tokenizer_json_path = Path(pretrained_model_name_or_path) / "tokenizer.json"
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
print(f"[bold cyan]Language:[/bold cyan] {language.name}")
|
print(f"[bold cyan]Language:[/bold cyan] {language.name}")
|
||||||
@@ -68,7 +68,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# モデルを ONNX に変換
|
# モデルを ONNX に変換
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
print(f"[bold cyan]Exporting ONNX model...[/bold cyan]")
|
print("[bold cyan]Exporting ONNX model...[/bold cyan]")
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
export_start_time = time.time()
|
export_start_time = time.time()
|
||||||
torch.onnx.export(
|
torch.onnx.export(
|
||||||
@@ -98,7 +98,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# ONNX モデルを最適化
|
# ONNX モデルを最適化
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
print(f"[bold cyan]Optimizing ONNX model...[/bold cyan]")
|
print("[bold cyan]Optimizing ONNX model...[/bold cyan]")
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
optimize_start_time = time.time()
|
optimize_start_time = time.time()
|
||||||
onnx_model = onnx.load(onnx_temp_model_path)
|
onnx_model = onnx.load(onnx_temp_model_path)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Usage: .venv/bin/python convert_onnx.py --model model_assets/koharune-ami/koharune-ami.safetensors
|
# Usage: python convert_onnx.py --model model_assets/koharune-ami/koharune-ami.safetensors
|
||||||
# Usage: .venv/bin/python convert_onnx.py --model model_assets/ (All models in the directory will be converted)
|
# Usage: python convert_onnx.py --model model_assets/ (All models in the directory will be converted)
|
||||||
# ref: https://github.com/tuna2134/sbv2-api/blob/main/convert/convert_model.py
|
# ref: https://github.com/tuna2134/sbv2-api/blob/main/convert/convert_model.py
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@@ -162,7 +162,7 @@ if __name__ == "__main__":
|
|||||||
# モデルを ONNX に変換
|
# モデルを ONNX に変換
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
print(
|
print(
|
||||||
f"[bold cyan]Exporting ONNX model... (Architecture: JP-Extra)[/bold cyan]"
|
"[bold cyan]Exporting ONNX model... (Architecture: JP-Extra)[/bold cyan]"
|
||||||
)
|
)
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
export_start_time = time.time()
|
export_start_time = time.time()
|
||||||
@@ -253,7 +253,7 @@ if __name__ == "__main__":
|
|||||||
# モデルを ONNX に変換
|
# モデルを ONNX に変換
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
print(
|
print(
|
||||||
f"[bold cyan]Exporting ONNX model... (Architecture: Non-JP-Extra)[/bold cyan]"
|
"[bold cyan]Exporting ONNX model... (Architecture: Non-JP-Extra)[/bold cyan]"
|
||||||
)
|
)
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
export_start_time = time.time()
|
export_start_time = time.time()
|
||||||
@@ -310,7 +310,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# ONNX モデルを最適化
|
# ONNX モデルを最適化
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
print(f"[bold cyan]Optimizing ONNX model...[/bold cyan]")
|
print("[bold cyan]Optimizing ONNX model...[/bold cyan]")
|
||||||
print(Rule(characters="=", style=Style(color="blue")))
|
print(Rule(characters="=", style=Style(color="blue")))
|
||||||
optimize_start_time = time.time()
|
optimize_start_time = time.time()
|
||||||
onnx_model = onnx.load(onnx_temp_model_path)
|
onnx_model = onnx.load(onnx_temp_model_path)
|
||||||
|
|||||||
@@ -897,7 +897,7 @@ initial_md = """
|
|||||||
- 話者数が違うモデル同士はおそらくマージできません。
|
- 話者数が違うモデル同士はおそらくマージできません。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
style_merge_md = f"""
|
style_merge_md = """
|
||||||
## 3. スタイルベクトルのマージ
|
## 3. スタイルベクトルのマージ
|
||||||
|
|
||||||
1. マージ後のモデルにいくつスタイルを追加したいかを「作りたいスタイル数」で指定
|
1. マージ後のモデルにいくつスタイルを追加したいかを「作りたいスタイル数」で指定
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from random import sample, shuffle
|
from random import sample
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from typing import Any, Optional, Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import onnxruntime
|
import onnxruntime
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import torch
|
|||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
|
|
||||||
from style_bert_vits2.logging import logger
|
from style_bert_vits2.logging import logger
|
||||||
from style_bert_vits2.models.utils import checkpoints # type: ignore
|
from style_bert_vits2.models.utils import (
|
||||||
from style_bert_vits2.models.utils import safetensors # type: ignore
|
checkpoints, # type: ignore
|
||||||
|
safetensors, # type: ignore
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||||
|
|
||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ def unload_tokenizer(language: Languages) -> None:
|
|||||||
language (Languages): アンロードする BERT トークナイザーの言語
|
language (Languages): アンロードする BERT トークナイザーの言語
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import torch
|
|
||||||
|
|
||||||
if language in __loaded_tokenizers:
|
if language in __loaded_tokenizers:
|
||||||
del __loaded_tokenizers[language]
|
del __loaded_tokenizers[language]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ Style-Bert-VITS2 の ONNX 推論に必要な各言語ごとの ONNX 版 BERT モ
|
|||||||
|
|
||||||
import gc
|
import gc
|
||||||
import time
|
import time
|
||||||
|
from collections.abc import Sequence
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Optional, Sequence, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
import onnxruntime
|
import onnxruntime
|
||||||
from huggingface_hub import hf_hub_download
|
from huggingface_hub import hf_hub_download
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import gc
|
import gc
|
||||||
import time
|
import time
|
||||||
|
from collections.abc import Sequence
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import onnxruntime
|
import onnxruntime
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from typing import Any, Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
from typing import Any, Union
|
||||||
|
|
||||||
|
|
||||||
def torch_device_to_onnx_providers(
|
def torch_device_to_onnx_providers(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from typing import Any, Literal, Sequence
|
from collections.abc import Sequence
|
||||||
|
from typing import Any, Literal
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from scipy.io import wavfile
|
from scipy.io import wavfile
|
||||||
|
|||||||
Reference in New Issue
Block a user