more logging

This commit is contained in:
Brandon Thomas
2023-05-04 06:31:39 -07:00
parent 5187ffbd7b
commit b52e1c3f88
4 changed files with 33 additions and 2 deletions
@@ -196,6 +196,10 @@ def infer(
):
"""Inference"""
#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
if not auto_predict_f0:
@@ -796,7 +796,7 @@ def clean():
"-d",
"--device",
type=str,
default="cpu",
default="cuda",
help="device to use",
)
def onnx(
@@ -141,7 +141,7 @@ class Svc:
_ = utils.load_checkpoint(self.net_g_path, self.net_g, None)
LOG.info(f"Svc.load_model() utils.load_checkpoit() END")
_ = self.net_g.eval().to(self.device, dtype=self.dtype)
def get_unit_f0(
@@ -154,12 +154,18 @@ class Svc:
"crepe", "crepe-tiny", "parselmouth", "dio", "harvest"
] = "dio",
):
LOG.info(f"Svc.get_unit_f0() compute_f0 BEGIN")
f0 = so_vits_svc_f0.compute_f0(
audio,
sampling_rate=self.target_sample,
hop_length=self.hop_size,
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 = torch.as_tensor(f0, 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)
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(
self.hubert_model,
audio,
@@ -174,15 +184,27 @@ class Svc:
self.target_sample,
self.contentvec_final_proj,
).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])
LOG.info(f"Svc.get_unit_f0() utils.repeat_expand_2d END")
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(
self.cluster_model, c.cpu().numpy().T, speaker
).T
cluster_c = torch.FloatTensor(cluster_c).to(self.device)
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)
return c, f0, uv
@@ -29,19 +29,24 @@ HUBERT_SAMPLING_RATE = 16000
def get_optimal_device(index: int = 0) -> torch.device:
LOG.warn("util.get_optimal_device()")
if torch.cuda.is_available():
LOG.warn("util.get_optimal_device() ... cuda")
return torch.device(f"cuda:{index % torch.cuda.device_count()}")
elif torch.backends.mps.is_available():
LOG.warn("util.get_optimal_device() ... mps")
return torch.device("mps")
else:
try:
import torch_xla.core.xla_model as xm # noqa
if xm.xrt_world_size() > 0:
LOG.warn("util.get_optimal_device() ... xla")
return torch.device("xla")
# return xm.xla_device()
except ImportError:
pass
LOG.warn("util.get_optimal_device() ... cpu")
return torch.device("cpu")