yl4579 / StarGANv2-VC

StarGANv2-VC: A Diverse, Unsupervised, Non-parallel Framework for Natural-Sounding Voice Conversion
MIT License
479 stars 107 forks source link

a bug about val_list.txt #42

Closed vanetspark closed 2 years ago

vanetspark commented 2 years ago

1、代码有个bug,val_list 一共301条语音,但是 val过程中,却没有使用dataloader的 drop last 功能,结果导致在losses.py里面出了一个bug ,就是说 f0_mean.shape报错:

File "/data/private/user43/workspace/voice_conversion_projs/StarGANv2-VC/losses.py", line 106, in compute_g_loss loss_f0 = f0_loss(F0_fake, F0_real) File "/data/private/user43/workspace/voice_conversion_projs/StarGANv2-VC/losses.py", line 212, in f0_loss x_mean = compute_mean_f0(x_f0) File "/data/private/user43/workspace/voice_conversion_projs/StarGANv2-VC/losses.py", line 203, in compute_mean_f0 f0_mean = f0_mean.expand(f0.shape[-1], f0_mean.shape[0]).transpose(0, 1) # (B, M) IndexError: tuple index out of range

这是因为val过程中每次取5条语音进行验证,结果 301 / 5 余1,导致最后一个语音的f0的张量的维度是(L),取mean(-1)以后变成空。 于是f0_mean.shape[0] 越界。

因此,最好的做法是将val list .txt 删除一行。并最好将 build dataset处的init函数中的 [ l[:-1].split("|") ]改成 [ l.strip("\n").split("|") ], 避免由于换行符去除失败又导致无法建立dataset。

yl4579 commented 2 years ago

If I understand correctly, I believe this will only happen when the remainder of the number of lines in val_list.txt divided by the batch size is 1. I don't think there's any way to fix this. For example, if you have 301 samples and your batch size is 5, even if there's no extra line at the end of val_list.txt, there'll still be a problem. You can try to fix the .mean(-1) part though.

vanetspark commented 2 years ago

thank you for replying me , my English is poor ,but your understanding is correct and I has solved this problem. The code has very good effects , thank you very much