mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2025-05-06 20:01:37 +08:00
fix(web): unload model error
IndexError: tuple index out of range
This commit is contained in:
parent
17e703a9ad
commit
ccecac6133
@ -53,7 +53,7 @@
|
|||||||
"加载预训练底模D路径": "Load pre-trained base model D path",
|
"加载预训练底模D路径": "Load pre-trained base model D path",
|
||||||
"加载预训练底模G路径": "Load pre-trained base model G path",
|
"加载预训练底模G路径": "Load pre-trained base model G path",
|
||||||
"单次推理": "Single Inference",
|
"单次推理": "Single Inference",
|
||||||
"卸载音色省显存": "Unload voice to save GPU memory",
|
"卸载音色省显存": "Unload model to save GPU memory",
|
||||||
"变调(整数, 半音数量, 升八度12降八度-12)": "Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12)",
|
"变调(整数, 半音数量, 升八度12降八度-12)": "Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12)",
|
||||||
"后处理重采样至最终采样率,0为不进行重采样": "Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
|
"后处理重采样至最终采样率,0为不进行重采样": "Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
|
||||||
"否": "No",
|
"否": "No",
|
||||||
|
@ -1093,7 +1093,7 @@ with gr.Blocks(title="RVC WebUI") as app:
|
|||||||
)
|
)
|
||||||
sid0.change(
|
sid0.change(
|
||||||
fn=vc.get_vc,
|
fn=vc.get_vc,
|
||||||
inputs=[sid0, protect0, protect1],
|
inputs=[sid0, protect0, protect1, file_index2, file_index4],
|
||||||
outputs=[
|
outputs=[
|
||||||
spk_item,
|
spk_item,
|
||||||
protect0,
|
protect0,
|
||||||
|
@ -190,6 +190,7 @@ def _extend_difference(n, a, b):
|
|||||||
|
|
||||||
|
|
||||||
def hash_similarity(h1: str, h2: str) -> float:
|
def hash_similarity(h1: str, h2: str) -> float:
|
||||||
|
try:
|
||||||
h1b, h2b = decode_from_string(h1), decode_from_string(h2)
|
h1b, h2b = decode_from_string(h1), decode_from_string(h2)
|
||||||
if len(h1b) != half_hash_len * 2 or len(h2b) != half_hash_len * 2:
|
if len(h1b) != half_hash_len * 2 or len(h2b) != half_hash_len * 2:
|
||||||
raise Exception("invalid hash length")
|
raise Exception("invalid hash length")
|
||||||
@ -211,6 +212,8 @@ def hash_similarity(h1: str, h2: str) -> float:
|
|||||||
)
|
)
|
||||||
distance = _extend_difference(np.exp(-d / expand_factor), 0.5, 1.0)
|
distance = _extend_difference(np.exp(-d / expand_factor), 0.5, 1.0)
|
||||||
return round((abs(cosine) + distance) / 2, 6)
|
return round((abs(cosine) + distance) / 2, 6)
|
||||||
|
except Exception as e:
|
||||||
|
return str(e)
|
||||||
|
|
||||||
|
|
||||||
def hash_id(h: str) -> str:
|
def hash_id(h: str) -> str:
|
||||||
|
@ -89,11 +89,15 @@ class VC:
|
|||||||
elif torch.backends.mps.is_available():
|
elif torch.backends.mps.is_available():
|
||||||
torch.mps.empty_cache()
|
torch.mps.empty_cache()
|
||||||
return (
|
return (
|
||||||
|
(
|
||||||
{"visible": False, "__type__": "update"},
|
{"visible": False, "__type__": "update"},
|
||||||
to_return_protect0,
|
to_return_protect0,
|
||||||
to_return_protect1,
|
to_return_protect1,
|
||||||
"",
|
{"value": to_return_protect[2], "__type__": "update"},
|
||||||
"",
|
{"value": to_return_protect[3], "__type__": "update"},
|
||||||
|
{"value": "", "__type__": "update"},
|
||||||
|
) if to_return_protect
|
||||||
|
else {"visible": True, "maximum": 0, "__type__": "update"}
|
||||||
)
|
)
|
||||||
person = f'{os.getenv("weight_root")}/{sid}'
|
person = f'{os.getenv("weight_root")}/{sid}'
|
||||||
logger.info(f"Loading: {person}")
|
logger.info(f"Loading: {person}")
|
||||||
@ -221,10 +225,10 @@ class VC:
|
|||||||
% (index_info, *times),
|
% (index_info, *times),
|
||||||
(tgt_sr, audio_opt),
|
(tgt_sr, audio_opt),
|
||||||
)
|
)
|
||||||
except:
|
except Exception as e:
|
||||||
info = traceback.format_exc()
|
info = traceback.format_exc()
|
||||||
logger.warning(info)
|
logger.warning(info)
|
||||||
return info, (None, None)
|
return str(e), None
|
||||||
|
|
||||||
def vc_multi(
|
def vc_multi(
|
||||||
self,
|
self,
|
||||||
|
@ -253,7 +253,10 @@ class Pipeline(object):
|
|||||||
# _, I = index.search(npy, 1)
|
# _, I = index.search(npy, 1)
|
||||||
# npy = big_npy[I.squeeze()]
|
# npy = big_npy[I.squeeze()]
|
||||||
|
|
||||||
|
try:
|
||||||
score, ix = index.search(npy, k=8)
|
score, ix = index.search(npy, k=8)
|
||||||
|
except:
|
||||||
|
raise Exception("index mistatch")
|
||||||
weight = np.square(1 / score)
|
weight = np.square(1 / score)
|
||||||
weight /= weight.sum(axis=1, keepdims=True)
|
weight /= weight.sum(axis=1, keepdims=True)
|
||||||
npy = np.sum(big_npy[ix] * np.expand_dims(weight, axis=2), axis=1)
|
npy = np.sum(big_npy[ix] * np.expand_dims(weight, axis=2), axis=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user