Apply black formatter
This commit is contained in:
@@ -107,7 +107,9 @@ def plot_spectrogram_to_numpy(spectrogram: NDArray[Any]) -> NDArray[Any]:
|
||||
return data
|
||||
|
||||
|
||||
def plot_alignment_to_numpy(alignment: NDArray[Any], info: Optional[str] = None) -> NDArray[Any]:
|
||||
def plot_alignment_to_numpy(
|
||||
alignment: NDArray[Any], info: Optional[str] = None
|
||||
) -> NDArray[Any]:
|
||||
"""
|
||||
指定されたアライメントを画像データに変換する
|
||||
|
||||
@@ -163,7 +165,9 @@ def load_wav_to_torch(full_path: Union[str, Path]) -> tuple[torch.FloatTensor, i
|
||||
return torch.FloatTensor(data.astype(np.float32)), sampling_rate
|
||||
|
||||
|
||||
def load_filepaths_and_text(filename: Union[str, Path], split: str = "|") -> list[list[str]]:
|
||||
def load_filepaths_and_text(
|
||||
filename: Union[str, Path], split: str = "|"
|
||||
) -> list[list[str]]:
|
||||
"""
|
||||
指定されたファイルからファイルパスとテキストを読み込む
|
||||
|
||||
@@ -180,7 +184,9 @@ def load_filepaths_and_text(filename: Union[str, Path], split: str = "|") -> lis
|
||||
return filepaths_and_text
|
||||
|
||||
|
||||
def get_logger(model_dir_path: Union[str, Path], filename: str = "train.log") -> logging.Logger:
|
||||
def get_logger(
|
||||
model_dir_path: Union[str, Path], filename: str = "train.log"
|
||||
) -> logging.Logger:
|
||||
"""
|
||||
ロガーを取得する
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ def load_checkpoint(
|
||||
model: torch.nn.Module,
|
||||
optimizer: Optional[torch.optim.Optimizer] = None,
|
||||
skip_optimizer: bool = False,
|
||||
for_infer: bool = False
|
||||
for_infer: bool = False,
|
||||
) -> tuple[torch.nn.Module, Optional[torch.optim.Optimizer], float, int]:
|
||||
"""
|
||||
指定されたパスからチェックポイントを読み込み、モデルとオプティマイザーを更新する。
|
||||
@@ -107,7 +107,9 @@ def save_checkpoint(
|
||||
iteration (int): イテレーション数
|
||||
checkpoint_path (Union[str, Path]): 保存先のパス
|
||||
"""
|
||||
logger.info(f"Saving model and optimizer state at iteration {iteration} to {checkpoint_path}")
|
||||
logger.info(
|
||||
f"Saving model and optimizer state at iteration {iteration} to {checkpoint_path}"
|
||||
)
|
||||
if hasattr(model, "module"):
|
||||
state_dict = model.module.state_dict()
|
||||
else:
|
||||
@@ -123,7 +125,11 @@ def save_checkpoint(
|
||||
)
|
||||
|
||||
|
||||
def clean_checkpoints(model_dir_path: Union[str, Path] = "logs/44k/", n_ckpts_to_keep: int = 2, sort_by_time: bool = True) -> None:
|
||||
def clean_checkpoints(
|
||||
model_dir_path: Union[str, Path] = "logs/44k/",
|
||||
n_ckpts_to_keep: int = 2,
|
||||
sort_by_time: bool = True,
|
||||
) -> None:
|
||||
"""
|
||||
指定されたディレクトリから古いチェックポイントを削除して空き容量を確保する
|
||||
|
||||
@@ -172,7 +178,9 @@ def clean_checkpoints(model_dir_path: Union[str, Path] = "logs/44k/", n_ckpts_to
|
||||
[del_routine(fn) for fn in to_del]
|
||||
|
||||
|
||||
def get_latest_checkpoint_path(model_dir_path: Union[str, Path], regex: str = "G_*.pth") -> str:
|
||||
def get_latest_checkpoint_path(
|
||||
model_dir_path: Union[str, Path], regex: str = "G_*.pth"
|
||||
) -> str:
|
||||
"""
|
||||
指定されたディレクトリから最新のチェックポイントのパスを取得する
|
||||
|
||||
|
||||
Reference in New Issue
Block a user