Skip to content

Commit

Permalink
only save added index
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisewf committed Sep 14, 2024
1 parent e116ae3 commit 95c6677
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rvc/train/process/extract_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
index_filename_added = f"added_{model_name}_{version}.index"
index_filepath_added = os.path.join(exp_dir, index_filename_added)

index_filename_trained = f"trained_{model_name}_{version}.index"
index_filepath_trained = os.path.join(exp_dir, index_filename_trained)
# index_filename_trained = f"trained_{model_name}_{version}.index"
# index_filepath_trained = os.path.join(exp_dir, index_filename_trained)

if os.path.exists(index_filepath_trained) and os.path.exists(index_filepath_added):
if os.path.exists(index_filepath_added):
pass
else:
npys = []
Expand Down Expand Up @@ -52,10 +52,11 @@
.cluster_centers_
)

np.save(os.path.join(exp_dir, "total_fea.npy"), big_npy)
# np.save(os.path.join(exp_dir, "total_fea.npy"), big_npy)

n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39)

"""
# index_trained
index_trained = faiss.index_factory(
256 if version == "v1" else 768, f"IVF{n_ivf},Flat"
Expand All @@ -65,6 +66,7 @@
index_trained.train(big_npy)
faiss.write_index(index_trained, index_filepath_trained)
"""

# index_added
index_added = faiss.index_factory(
Expand Down

0 comments on commit 95c6677

Please sign in to comment.