Rayhane-mamah / Tacotron-2

DeepMind's Tacotron-2 Tensorflow implementation
MIT License
2.25k stars 911 forks source link

An AttributeError? #382

Open Joee1995 opened 5 years ago

Joee1995 commented 5 years ago

Hi, thx @Rayhane-mamah for this great job first. When running python synthesize.py --model='Tacotron', i receive en error as follow:

Starting Synthesis Traceback (most recent call last): File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in wrapfunc return getattr(obj, method)(*args, **kwds) AttributeError: 'list' object has no attribute 'round' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "synthesize.py", line 101, in main() File "synthesize.py", line 91, in main = tacotron_synthesize(args, hparams, taco_checkpoint, sentences) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize return run_eval(args, checkpoint_path, output_dir, hparams, sentences) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 152, in synthesize target_lengths = self._get_output_lengths(stop_tokens) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 256, in _get_output_lengths output_lengths = [row.index(1) if 1 in row else len(row) for row in np.round(stoptokens).tolist()] File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2851, in round return around(a, decimals=decimals, out=out) File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2837, in around return _wrapfunc(a, 'round', decimals=decimals, out=out) File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc return _wrapit(obj, method, *args, *kwds) File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit result = getattr(asarray(obj), method)(args, **kwds) AttributeError: 'numpy.ndarray' object has no attribute 'rint'

I think i do something wrong. Anyone can help me?

RytisKumpa commented 5 years ago

I have the exact same error, except mine says: 'list' object has no attribute 'clip'. I've tried installing multiple different versions of numpy to no avail.

However, running synthesis on one GPU solved it. If you're training on multiple GPUs, try running synthesis just on one. Hope that helps.

Joee1995 commented 5 years ago

@RytisKumpa I try to run with one GPU, but receive this error:

Starting Synthesis Traceback (most recent call last): File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in wrapfunc return getattr(obj, method)(*args, **kwds) AttributeError: 'list' object has no attribute 'clip' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "synthesize.py", line 101, in main() File "synthesize.py", line 91, in main = tacotron_synthesize(args, hparams, taco_checkpoint, sentences) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize return run_eval(args, checkpoint_path, output_dir, hparams, sentences) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 157, in synthesize linears = np.clip(linears, T2_output_range[0], T2_output_range[1]) File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1775, in clip return _wrapfunc(a, 'clip', a_min, a_max, out=out) File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc return _wrapit(obj, method, *args, *kwds) File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit result = getattr(asarray(obj), method)(args, **kwds) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Joee1995 commented 5 years ago

@RytisKumpa It's ok when I train model with one gpu too.

Joee1995 commented 5 years ago

I'm so sorry, but I receive this error again.

Starting Synthesis Traceback (most recent call last): File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in wrapfunc return getattr(obj, method)(*args, **kwds) AttributeError: 'list' object has no attribute 'clip' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "synthesize.py", line 103, in main() File "synthesize.py", line 93, in main = tacotron_synthesize(args, hparams, taco_checkpoint, sentences) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize return run_eval(args, checkpoint_path, output_dir, hparams, sentences) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None) File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 157, in synthesize linears = np.clip(linears, T2_output_range[0], T2_output_range[1]) File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1775, in clip return _wrapfunc(a, 'clip', a_min, a_max, out=out) File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc return _wrapit(obj, method, *args, *kwds) File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit result = getattr(asarray(obj), method)(args, **kwds) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I have no idea. Anyone can help me?

Joee1995 commented 5 years ago

I already run synthesis on one GPU.

Joee1995 commented 5 years ago

@RytisKumpa Can u tell me your numpy version? I have already run synthesis on one GPU, but got the same error.

RytisKumpa commented 5 years ago

Hmmm, I don't really know then... My numpy version that it worked with was the same as in the requirements.txt (numpy==1.14.0) Are you sure you did't change the num of GPUs used in hparams? From the code I can see that somewhere in the loop it returns a list if there are more than one GPU.

Joee1995 commented 5 years ago

Yes, I'm sure. My hparams.py:

tacotron_num_gpus = 1, wavenet_num_gpus = 1,

I have no idea how to fix it.

ZLZ-Nancy commented 5 years ago

Hello,I have the same problem, 'The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()',did you solve it?

sapinedamo commented 5 years ago

Hello. I get the same problem.

Starting Synthesis 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc return getattr(obj, method)(*args, **kwds) AttributeError: 'list' object has no attribute 'clip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "synthesize.py", line 100, in main() File "synthesize.py", line 94, in main synthesize(args, hparams, taco_checkpoint, wave_checkpoint, sentences) File "synthesize.py", line 36, in synthesize wavenet_in_dir = tacotron_synthesize(args, hparams, taco_checkpoint, sentences) File "/home/csanta/tacotron2/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize return run_eval(args, checkpoint_path, output_dir, hparams, sentences) File "/home/csanta/tacotron2/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None) File "/home/csanta/tacotron2/Tacotron-2/tacotron/synthesizer.py", line 157, in synthesize linears = np.clip(linears, T2_output_range[0], T2_output_range[1]) File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 1775, in clip return _wrapfunc(a, 'clip', a_min, a_max, out=out) File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc return _wrapit(obj, method, *args, *kwds) File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit result = getattr(asarray(obj), method)(args, **kwds) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I need to fix it.

TheButlah commented 5 years ago

Same issue as @sapinedamo. I am using two GPUs and a batch size of 1024

FreezingGod commented 4 years ago

This is because mels and linears are lists and numpy cannot apply clip on them. Changing line 183 of tacotron/synthesizer.py from linears = np.clip(linears, T2_output_range[0], T2_output_range[1]) to linears = [np.clip(i, T2_output_range[0], T2_output_range[1]) for i in linears], line 186 from mels = np.clip(mels, T2_output_range[0], T2_output_range[1]) to mels = [np.clip(i, T2_output_range[0], T2_output_range[1]) for i in mels] and line 296-297 to output_lengths = [row.index(1) if 1 in row else len(row) for row in [np.round(i).tolist() for i in stop_tokens]] works for me.