so-vits-svc-fork
so-vits-svc-fork copied to clipboard
gui.py: Proposed default model is wrong due to bad sorting
Assume you have two G_xx.pth files in logs/44k folder: These two files are:
G_99.pth and G_100.pth
Then, gui.py will incorrectly propose G_99.pth as the default model instead of G_100.pth This is occurs because (gui.py: line 180):
list(sorted(Path("./logs/44k/").glob("G_*.pth")))
will sort them alphabetically... Which is clearly not the point.
The solution is to add the following function getint(posix_path) (with the needed import) at the beginning of gui.py:
import os
def getint(posix_path):
n=int(posix_path.name.split(os.sep)[-1].split('.')[0].split('_')[1])
return n
and replace line 180 with the following two lines:
model_candidates = list(Path("./logs/44k/").glob("G_*.pth"))
model_candidates.sort(key=getint)
This is due to the sorted() method. For example:
def getint(str_value):
n=int(str_value)
return n
L=['10','1','2']
print('Sorted with sorted(): ',sorted(L))
L.sort(key=getint)
print('Properly sorted with getint() as key: ',L)
will output:
Sorted with sorted(): ['1', '10', '2']
Properly sorted with getint() as key: ['1', '2', '10']
Just for reference: Screen recordings before and after correction
Before correction:
https://github.com/voicepaw/so-vits-svc-fork/assets/34165937/79d18b93-3b6c-4f12-98c2-8c98d5cbfd87
After correction:
https://github.com/voicepaw/so-vits-svc-fork/assets/34165937/9e626b84-b07b-4485-b471-4e481aa2301f
@34j : Since this my first commit submission, I'd like to know if I did it correctly. Is it OK?
@34j : Since this my first commit submission, I'd like to know if I did it correctly. Is it OK?
Thank you, but not very OK. See the docs: https://so-vits-svc-fork.readthedocs.io/en/latest/contributing.html
@34j : OK. I'll try again. I'll restart from scratch.