Improve: Change inefficient processes

This commit is contained in:
w-okada 2023-07-18 08:36:21 +09:00
parent 0957fbc923
commit 87a10c8e11

View File

@ -136,7 +136,6 @@ class Pipeline(object):
feats = feats.view(1, -1) feats = feats.view(1, -1)
# embedding # embedding
padding_mask = torch.BoolTensor(feats.shape).to(self.device).fill_(False)
with autocast(enabled=self.isHalf): with autocast(enabled=self.isHalf):
try: try:
feats = self.embedder.extractFeatures(feats, embOutputLayer, useFinalProj) feats = self.embedder.extractFeatures(feats, embOutputLayer, useFinalProj)
@ -149,8 +148,6 @@ class Pipeline(object):
raise DeviceChangingException() raise DeviceChangingException()
else: else:
raise e raise e
if protect < 0.5 and search_index:
feats0 = feats.clone()
# Index - feature抽出 # Index - feature抽出
# if self.index is not None and self.feature is not None and index_rate != 0: # if self.index is not None and self.feature is not None and index_rate != 0:
@ -179,7 +176,7 @@ class Pipeline(object):
feats = torch.from_numpy(npy).unsqueeze(0).to(self.device) * index_rate + (1 - index_rate) * feats feats = torch.from_numpy(npy).unsqueeze(0).to(self.device) * index_rate + (1 - index_rate) * feats
feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1) feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1)
if protect < 0.5 and search_index: if protect < 0.5 and search_index:
feats0 = F.interpolate(feats0.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1) feats0 = feats.clone()
# ピッチサイズ調整 # ピッチサイズ調整
p_len = audio_pad.shape[0] // self.window p_len = audio_pad.shape[0] // self.window
@ -243,7 +240,7 @@ class Pipeline(object):
else: else:
pitchf_buffer = None pitchf_buffer = None
del p_len, padding_mask, pitch, pitchf, feats del p_len, pitch, pitchf, feats
torch.cuda.empty_cache() torch.cuda.empty_cache()
# inferで出力されるサンプリングレートはモデルのサンプリングレートになる。 # inferで出力されるサンプリングレートはモデルのサンプリングレートになる。