Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I meet a error about "Exception: Can't create RandomCycler from an empty collection" #47

Closed
sunnnnnnnny opened this issue Jul 15, 2019 · 20 comments
Labels
bug Something isn't working

Comments

@sunnnnnnnny
Copy link

The error message is as follows, I hope to get your reply.thanks

No model "my_run" found, starting training from scratch.
Updating the visualizations every 10 steps.
......Traceback (most recent call last):
File "encoder_train.py", line 47, in
train(**vars(args))
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/train.py", line 71, in train
for step, speaker_batch in enumerate(loader, init_step):
File "/home/zyq/miniconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 568, in next
return self._process_next_batch(batch)
File "/home/zyq/miniconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
Exception: Traceback (most recent call last):
File "/home/zyq/miniconda3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/data_objects/speaker_verification_dataset.py", line 56, in collate
return SpeakerBatch(speakers, self.utterances_per_speaker, partials_n_frames)
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/data_objects/speaker_batch.py", line 8, in init
self.partials = {s: s.random_partial(utterances_per_speaker, n_frames) for s in speakers}
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/data_objects/speaker_batch.py", line 8, in
self.partials = {s: s.random_partial(utterances_per_speaker, n_frames) for s in speakers}
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/data_objects/speaker.py", line 35, in random_partial
self._load_utterances()
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/data_objects/speaker.py", line 19, in _load_utterances
self.utterance_cycler = RandomCycler(self.utterances)
File "/home/zyq/speech/Real-Time-Voice-Cloning/encoder/data_objects/random_cycler.py", line 15, in init
raise Exception("Can't create RandomCycler from an empty collection")
Exception: Can't create RandomCycler from an empty collection

@CorentinJ
Copy link
Owner

Can you check the audio files in your datasets and check that they are indeed there?

@sunnnnnnnny
Copy link
Author

I confirmed this several times and the processed Librispeech file is there.

@CorentinJ
Copy link
Owner

Can you also check that you have the numpy files in the preprocessed directory, e.g. you should have:

<datasets_root>\SV2TTS\encoder\LibriSpeech_train-other-500_20\205_20-205-0000.npy

@sunnnnnnnny
Copy link
Author

I seem to solve this problem. It turned out that my original data has an illegal speaker folder. Thank you for helping me debug.

@fantasyHq
Copy link

@CorentinJ Hello! I 've read your code and paper for some days.A problem confuses me is that I don't understand the mean of "create RandomCycler ",what does the class do in dataloader? I appretiate it if you can explain it for me,Sorry I 'm new studier.

@Ravi-Singh88
Copy link

I seem to solve this problem. It turned out that my original data has an illegal speaker folder. Thank you for helping me debug.

@sunnnnnnnny How did you manage to find this illegal speaker folder

@237sankalp
Copy link

237sankalp commented Nov 4, 2020

I seem to solve this problem. It turned out that my original data has an illegal speaker folder. Thank you for helping me debug.

@sunnnnnnnny How did you manage to find this illegal speaker folder

The same problem, I am also not getting it how did you find an illegal speaker.

@ghost
Copy link

ghost commented Nov 4, 2020

This error message is encountered when there a subfolder in SV2TTS/encoder does not contain any .npy files. This happens because in preprocessing, folders are created for each speaker, but in some cases there are no valid files to populate the folder.

We should improve the preprocess code so the speaker folder is only created if it contains audio files. This is the line in question that should be moved:

speaker_out_dir.mkdir(exist_ok=True)

@237sankalp
Copy link

@blue-fish thanks,
doubt
for just experimenting I am providing the model with 1 speaker input but I am confused as to why the system is showing 2 speakers when I am only providing it with 1 speaker named "20". I think that the extra addition of the speaker is giving me the problem to train the encoder, as it is a null set.

@ghost
Copy link

ghost commented Nov 5, 2020

@237sankalp Check and see if you have a hidden folder in train-other-500. You can also check the value of speaker_dirs when this line is executed.

print("%s: Preprocessing data for %d speakers." % (dataset_name, len(speaker_dirs)))

@rishabhjain16
Copy link

rishabhjain16 commented Feb 24, 2021

I was stuck at the same place getting the same error. So I have written this helper script to figure out where the empty folders are and save them in a .txt file. I am taking length<2 as empty folders does contain source file.

import glob
import os

Dir = 'D:\mstts\SV2TTS\encoder'  #Source directory containing encoder preprocessed files 
OUTPUTFILE = r'D:\mstts\SV2TTS\folder.txt' #.txt destination directory

path = os.path.join(Dir, '*')
for folder in glob.glob(path):
    with open(OUTPUTFILE, 'a') as f:
        if len(os.listdir(folder)) < 2:
            f.write("{0} is a directory with No files'\n' ".format(folder))
        else:
            f.write("{0} is a directory with files'\n' ".format(folder))

Usage:

  1. Use this script to create a txt file with required information
  2. Look for folders where 'No files' is output
  3. Delete the folders from step 2 from your <dataset_root>/SVTTS/encoder

That's it, you are good to go.

@ghost
Copy link

ghost commented Feb 25, 2021

This is an issue that affects everyone training an encoder model. Some ideas to fix it:

  1. Modify encoder preprocessing to delete empty folders in datasets_root/SV2TTS/encoder before exiting.
  2. Fix the random cycler or the encoder training code so it doesn't break when empty folders are present.

@ghost ghost reopened this Feb 25, 2021
@rishabhjain16
Copy link

Hi @blue-fish ,

I am training my encoder model at the moment. But I can take a look at it next week (depending on the encoder results if I don't need to retrain it). Will let you know if I do make any changes.

@rishabhjain16
Copy link

rishabhjain16 commented Mar 4, 2021

Hi @blue-fish,

Just to give you an update, my encoder is still running, so couldn't make any changes so far.

I have another question though. I noticed in my encoder training that the loss and EER calculated and plotted on Visdom is based on training data. Is there any way to also test the model maybe on a validation dataset or if we can provide a split in the dataloader for testing and training? I am curious if I can test my trained Speaker Verification model on an unseen or test dataset for Loss and EER.

@ghost
Copy link

ghost commented Mar 4, 2021

@rishabhjain16 Thanks for the suggestion. I opened #689 for your idea.

@rishabhjain16
Copy link

No worries. It seems like a great tool. So I am happy to contribute however I can.

@ghost ghost added the bug Something isn't working label Mar 7, 2021
@rishabhjain16

This comment has been minimized.

@ghost
Copy link

ghost commented Mar 9, 2021

@rishabhjain16 Please stay on topic. In the future, open a new issue to ask unrelated questions.

  1. The synthesizer must be retrained if the encoder is changed.
  2. I don't use MFA. Set up your dataset in this format and use the --no_alignments option for preprocessing.

@rishabhjain16
Copy link

Hi @blue-fish ,

Sorry about that. I will keep that in mind for future discussions. And thank you for your help.

@erfanlashkari
Copy link

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants