mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-28 09:08:54 +00:00
more logging
This commit is contained in:
@@ -196,6 +196,10 @@ def infer(
|
|||||||
):
|
):
|
||||||
"""Inference"""
|
"""Inference"""
|
||||||
#from .inference_main import infer
|
#from .inference_main import infer
|
||||||
|
|
||||||
|
LOG.warning(f"Using device: {device}")
|
||||||
|
LOG.warning(f"Model path: {model_path}")
|
||||||
|
|
||||||
from so_vits_svc_fork.inference.main import infer
|
from so_vits_svc_fork.inference.main import infer
|
||||||
|
|
||||||
if not auto_predict_f0:
|
if not auto_predict_f0:
|
||||||
|
|||||||
@@ -796,7 +796,7 @@ def clean():
|
|||||||
"-d",
|
"-d",
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
default="cpu",
|
default="cuda",
|
||||||
help="device to use",
|
help="device to use",
|
||||||
)
|
)
|
||||||
def onnx(
|
def onnx(
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class Svc:
|
|||||||
_ = utils.load_checkpoint(self.net_g_path, self.net_g, None)
|
_ = utils.load_checkpoint(self.net_g_path, self.net_g, None)
|
||||||
|
|
||||||
LOG.info(f"Svc.load_model() utils.load_checkpoit() END")
|
LOG.info(f"Svc.load_model() utils.load_checkpoit() END")
|
||||||
|
|
||||||
_ = self.net_g.eval().to(self.device, dtype=self.dtype)
|
_ = self.net_g.eval().to(self.device, dtype=self.dtype)
|
||||||
|
|
||||||
def get_unit_f0(
|
def get_unit_f0(
|
||||||
@@ -154,12 +154,18 @@ class Svc:
|
|||||||
"crepe", "crepe-tiny", "parselmouth", "dio", "harvest"
|
"crepe", "crepe-tiny", "parselmouth", "dio", "harvest"
|
||||||
] = "dio",
|
] = "dio",
|
||||||
):
|
):
|
||||||
|
LOG.info(f"Svc.get_unit_f0() compute_f0 BEGIN")
|
||||||
|
|
||||||
f0 = so_vits_svc_f0.compute_f0(
|
f0 = so_vits_svc_f0.compute_f0(
|
||||||
audio,
|
audio,
|
||||||
sampling_rate=self.target_sample,
|
sampling_rate=self.target_sample,
|
||||||
hop_length=self.hop_size,
|
hop_length=self.hop_size,
|
||||||
method=f0_method,
|
method=f0_method,
|
||||||
)
|
)
|
||||||
|
LOG.info(f"Svc.get_unit_f0() compute_f0 END")
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() interpolate_f0 BEGIN")
|
||||||
|
|
||||||
f0, uv = so_vits_svc_f0.interpolate_f0(f0)
|
f0, uv = so_vits_svc_f0.interpolate_f0(f0)
|
||||||
f0 = torch.as_tensor(f0, dtype=self.dtype, device=self.device)
|
f0 = torch.as_tensor(f0, dtype=self.dtype, device=self.device)
|
||||||
uv = torch.as_tensor(uv, dtype=self.dtype, device=self.device)
|
uv = torch.as_tensor(uv, dtype=self.dtype, device=self.device)
|
||||||
@@ -167,6 +173,10 @@ class Svc:
|
|||||||
f0 = f0.unsqueeze(0)
|
f0 = f0.unsqueeze(0)
|
||||||
uv = uv.unsqueeze(0)
|
uv = uv.unsqueeze(0)
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() interpolate_f0 END")
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() utils.get_content BEGIN")
|
||||||
|
|
||||||
c = utils.get_content(
|
c = utils.get_content(
|
||||||
self.hubert_model,
|
self.hubert_model,
|
||||||
audio,
|
audio,
|
||||||
@@ -174,15 +184,27 @@ class Svc:
|
|||||||
self.target_sample,
|
self.target_sample,
|
||||||
self.contentvec_final_proj,
|
self.contentvec_final_proj,
|
||||||
).to(self.dtype)
|
).to(self.dtype)
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() utils.get_content END")
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() utils.repeat_expand_2d BEGIN")
|
||||||
|
|
||||||
c = utils.repeat_expand_2d(c.squeeze(0), f0.shape[1])
|
c = utils.repeat_expand_2d(c.squeeze(0), f0.shape[1])
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() utils.repeat_expand_2d END")
|
||||||
|
|
||||||
if cluster_infer_ratio != 0:
|
if cluster_infer_ratio != 0:
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() cluster.get_cluster_center_result BEGIN [ON CPU!!]")
|
||||||
|
|
||||||
cluster_c = cluster.get_cluster_center_result(
|
cluster_c = cluster.get_cluster_center_result(
|
||||||
self.cluster_model, c.cpu().numpy().T, speaker
|
self.cluster_model, c.cpu().numpy().T, speaker
|
||||||
).T
|
).T
|
||||||
cluster_c = torch.FloatTensor(cluster_c).to(self.device)
|
cluster_c = torch.FloatTensor(cluster_c).to(self.device)
|
||||||
c = cluster_infer_ratio * cluster_c + (1 - cluster_infer_ratio) * c
|
c = cluster_infer_ratio * cluster_c + (1 - cluster_infer_ratio) * c
|
||||||
|
|
||||||
|
LOG.info(f"Svc.get_unit_f0() cluster.get_cluster_center_result END [ON CPU!!]")
|
||||||
|
|
||||||
c = c.unsqueeze(0)
|
c = c.unsqueeze(0)
|
||||||
return c, f0, uv
|
return c, f0, uv
|
||||||
|
|
||||||
|
|||||||
@@ -29,19 +29,24 @@ HUBERT_SAMPLING_RATE = 16000
|
|||||||
|
|
||||||
|
|
||||||
def get_optimal_device(index: int = 0) -> torch.device:
|
def get_optimal_device(index: int = 0) -> torch.device:
|
||||||
|
LOG.warn("util.get_optimal_device()")
|
||||||
if torch.cuda.is_available():
|
if torch.cuda.is_available():
|
||||||
|
LOG.warn("util.get_optimal_device() ... cuda")
|
||||||
return torch.device(f"cuda:{index % torch.cuda.device_count()}")
|
return torch.device(f"cuda:{index % torch.cuda.device_count()}")
|
||||||
elif torch.backends.mps.is_available():
|
elif torch.backends.mps.is_available():
|
||||||
|
LOG.warn("util.get_optimal_device() ... mps")
|
||||||
return torch.device("mps")
|
return torch.device("mps")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import torch_xla.core.xla_model as xm # noqa
|
import torch_xla.core.xla_model as xm # noqa
|
||||||
|
|
||||||
if xm.xrt_world_size() > 0:
|
if xm.xrt_world_size() > 0:
|
||||||
|
LOG.warn("util.get_optimal_device() ... xla")
|
||||||
return torch.device("xla")
|
return torch.device("xla")
|
||||||
# return xm.xla_device()
|
# return xm.xla_device()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
LOG.warn("util.get_optimal_device() ... cpu")
|
||||||
return torch.device("cpu")
|
return torch.device("cpu")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user