mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-01-20 11:00:23 +00:00
fix: 卸载音色省显存
顺便将所有print换成了统一的logger
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
"""
|
||||
import os
|
||||
import traceback
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
import faiss
|
||||
@@ -23,11 +26,11 @@ big_npy = np.concatenate(npys, 0)
|
||||
big_npy_idx = np.arange(big_npy.shape[0])
|
||||
np.random.shuffle(big_npy_idx)
|
||||
big_npy = big_npy[big_npy_idx]
|
||||
print(big_npy.shape) # (6196072, 192)#fp32#4.43G
|
||||
logger.debug(big_npy.shape) # (6196072, 192)#fp32#4.43G
|
||||
if big_npy.shape[0] > 2e5:
|
||||
# if(1):
|
||||
info = "Trying doing kmeans %s shape to 10k centers." % big_npy.shape[0]
|
||||
print(info)
|
||||
logger.info(info)
|
||||
try:
|
||||
big_npy = (
|
||||
MiniBatchKMeans(
|
||||
@@ -42,7 +45,7 @@ if big_npy.shape[0] > 2e5:
|
||||
)
|
||||
except:
|
||||
info = traceback.format_exc()
|
||||
print(info)
|
||||
logger.warn(info)
|
||||
|
||||
np.save("tools/infer/big_src_feature_mi.npy", big_npy)
|
||||
|
||||
@@ -50,14 +53,14 @@ np.save("tools/infer/big_src_feature_mi.npy", big_npy)
|
||||
# big_npy=np.load("/bili-coeus/jupyter/jupyterhub-liujing04/vits_ch/inference_f0/big_src_feature_mi.npy")
|
||||
n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39)
|
||||
index = faiss.index_factory(768, "IVF%s,Flat" % n_ivf) # mi
|
||||
print("Training...")
|
||||
logger.info("Training...")
|
||||
index_ivf = faiss.extract_index_ivf(index) #
|
||||
index_ivf.nprobe = 1
|
||||
index.train(big_npy)
|
||||
faiss.write_index(
|
||||
index, "tools/infer/trained_IVF%s_Flat_baseline_src_feat_v2.index" % (n_ivf)
|
||||
)
|
||||
print("Adding...")
|
||||
logger.info("Adding...")
|
||||
batch_size_add = 8192
|
||||
for i in range(0, big_npy.shape[0], batch_size_add):
|
||||
index.add(big_npy[i : i + batch_size_add])
|
||||
|
||||
Reference in New Issue
Block a user