Retrieval-based-Voice-Conversion-WebUI icon indicating copy to clipboard operation
Retrieval-based-Voice-Conversion-WebUI copied to clipboard

When I do training, I get this error : AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'

Open hackman1973 opened this issue 10 months ago • 8 comments

2025-02-24 11:37:11 | INFO | main | Use gpus: 0 2025-02-24 11:37:11 | INFO | main | Execute: "C:\pinokio\api\rvc.pinokio.git\app\env\Scripts\python.exe" infer/modules/train/train.py -e "mi-test" -sr 48k -f0 1 -bs 8 -g 0 -te 20 -se 5 -pg assets/pretrained_v2/f0G48k.pth -pd assets/pretrained_v2/f0D48k.pth -l 0 -c 0 -sw 0 -v v2 INFO:mi-test:{'data': {'filter_length': 2048, 'hop_length': 480, 'max_wav_value': 32768.0, 'mel_fmax': None, 'mel_fmin': 0.0, 'n_mel_channels': 128, 'sampling_rate': 48000, 'win_length': 2048, 'training_files': './logs\mi-test/filelist.txt'}, 'model': {'filter_channels': 768, 'gin_channels': 256, 'hidden_channels': 192, 'inter_channels': 192, 'kernel_size': 3, 'n_heads': 2, 'n_layers': 6, 'p_dropout': 0, 'resblock': '1', 'resblock_dilation_sizes': [[1, 3, 5], [1, 3, 5], [1, 3, 5]], 'resblock_kernel_sizes': [3, 7, 11], 'spk_embed_dim': 109, 'upsample_initial_channel': 512, 'upsample_kernel_sizes': [24, 20, 4, 4], 'upsample_rates': [12, 10, 2, 2], 'use_spectral_norm': False}, 'train': {'batch_size': 8, 'betas': [0.8, 0.99], 'c_kl': 1.0, 'c_mel': 45, 'epochs': 20000, 'eps': 1e-09, 'fp16_run': True, 'init_lr_ratio': 1, 'learning_rate': 0.0001, 'log_interval': 200, 'lr_decay': 0.999875, 'seed': 1234, 'segment_size': 17280, 'warmup_epochs': 0}, 'model_dir': './logs\mi-test', 'experiment_dir': './logs\mi-test', 'save_every_epoch': 5, 'name': 'mi-test', 'total_epoch': 20, 'pretrainG': 'assets/pretrained_v2/f0G48k.pth', 'pretrainD': 'assets/pretrained_v2/f0D48k.pth', 'version': 'v2', 'gpus': '0', 'sample_rate': '48k', 'if_f0': 1, 'if_latest': 0, 'save_every_weights': '0', 'if_cache_data_in_gpu': 0} C:\pinokio\api\rvc.pinokio.git\app\env\lib\site-packages\torch\nn\utils\weight_norm.py:30: UserWarning: torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm. warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.") DEBUG:infer.lib.infer_pack.models:gin_channels: 256, self.spk_embed_dim: 109 INFO:mi-test:loaded pretrained assets/pretrained_v2/f0G48k.pth INFO:mi-test:<All keys matched successfully> INFO:mi-test:loaded pretrained assets/pretrained_v2/f0D48k.pth INFO:mi-test:<All keys matched successfully> C:\pinokio\api\rvc.pinokio.git\app\env\lib\site-packages\torch\autograd_init_.py:251: UserWarning: Grad strides do not match bucket view strides. This may indicate grad was not created according to the gradient layout contract, or that the param's strides changed since DDP was constructed. This is not an error, but may impair performance. grad.sizes() = [64, 1, 4], strides() = [4, 1, 1] bucket_view.sizes() = [64, 1, 4], strides() = [4, 4, 1] (Triggered internally at ..\torch\csrc\distributed\c10d\reducer.cpp:334.) Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass INFO:mi-test:Train Epoch: 1 [0%] INFO:mi-test:[0, 0.0001] INFO:mi-test:loss_disc=3.742, loss_gen=3.616, loss_fm=10.436,loss_mel=29.701, loss_kl=9.000 DEBUG:matplotlib:matplotlib data path: C:\pinokio\api\rvc.pinokio.git\app\env\lib\site-packages\matplotlib\mpl-data DEBUG:matplotlib:CONFIGDIR=C:\Users\trika.matplotlib DEBUG:matplotlib:interactive is False DEBUG:matplotlib:platform is win32 Process Process-1: Traceback (most recent call last): File "C:\pinokio\bin\miniconda\lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\pinokio\bin\miniconda\lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) File "C:\pinokio\api\rvc.pinokio.git\app\infer\modules\train\train.py", line 268, in run train_and_evaluate( File "C:\pinokio\api\rvc.pinokio.git\app\infer\modules\train\train.py", line 545, in train_and_evaluate "slice/mel_org": utils.plot_spectrogram_to_numpy( File "C:\pinokio\api\rvc.pinokio.git\app\infer\lib\train\utils.py", line 238, in plot_spectrogram_to_numpy data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="") AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'

hackman1973 avatar Feb 24 '25 09:02 hackman1973

you probably already seen this previous thread ? : https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/issues/2411 ... but it tryed the solution given there... and it didn't work for me. i'm still stuck.

Bartabok avatar Feb 27 '25 21:02 Bartabok

you probably already seen this previous thread ? : #2411 ... but it tryed the solution given there... and it didn't work for me. i'm still stuck.

matplotlib==3.7.0, numpy==1.26.4

yumo0228 avatar Feb 28 '25 16:02 yumo0228

you probably already seen this previous thread ? : #2411 ... but it tryed the solution given there... and it didn't work for me. i'm still stuck.

matplotlib==3.7.0, numpy==1.26.4

I had matplotlib 3.7.1 ==> installed 3.7.0 instead. I had numpy 1.23.5 (It's the one indicated in the requirements.txt of the github page) ... so ==> i installed 1.26.4

Same result :(

AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'

Bartabok avatar Feb 28 '25 17:02 Bartabok

After many, many tests... I finally fixed it in a very dumb way ;D To explain... I tryed to install and run RVC, starting with this video here : https://youtu.be/nXpBlC6OBw4?si=5hef-vd-44dgbXFh I did as he says.. clicked on the green Code button. copyed the url and "git clone" it ...ect... and here started all my problems.

Then...one hour ago... i decided to try an other way that i saw in other videos. I didn't use the Code button, but i clicked on the "Releases" link in the right column... then downloaded the Nvidia GPU package (as my Graphic card is an Nvidia). And... ... that's all.

Everything worked fine at first try. what a waste of time.

Bartabok avatar Mar 01 '25 16:03 Bartabok

was not a waste of time. you got it working, you learned something, and you shared it. thank you!

kaze-gif avatar Mar 04 '25 00:03 kaze-gif

After many, many tests... I finally fixed it in a very dumb way ;D To explain... I tryed to install and run RVC, starting with this video here : https://youtu.be/nXpBlC6OBw4?si=5hef-vd-44dgbXFh I did as he says.. clicked on the green Code button. copyed the url and "git clone" it ...ect... and here started all my problems.

Then...one hour ago... i decided to try an other way that i saw in other videos. I didn't use the Code button, but i clicked on the "Releases" link in the right column... then downloaded the Nvidia GPU package (as my Graphic card is an Nvidia). And... ... that's all.

can you help me do that too ? i have the same problem .. i installed it using a one line code shown in https://www.youtube.com/watch?v=Y8IxVVQBEpc and after a few minute of training i get AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'

i even tried downgrading matplotlib and numpy

Joseph-Sherman avatar Mar 17 '25 02:03 Joseph-Sherman

After many, many tests... I finally fixed it in a very dumb way ;D To explain... I tryed to install and run RVC, starting with this video here : https://youtu.be/nXpBlC6OBw4?si=5hef-vd-44dgbXFh I did as he says.. clicked on the green Code button. copyed the url and "git clone" it ...ect... and here started all my problems. Then...one hour ago... i decided to try an other way that i saw in other videos. I didn't use the Code button, but i clicked on the "Releases" link in the right column... then downloaded the Nvidia GPU package (as my Graphic card is an Nvidia). And... ... that's all.

can you help me do that too ? i have the same problem .. i installed it using a one line code shown in https://www.youtube.com/watch?v=Y8IxVVQBEpc and after a few minute of training i get AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'

i even tried downgrading matplotlib and numpy

I encourage you to try my method (as explained 2 messages above)... After spending days fighting with version conflicts, i installed what i think is the "standalone pack". It probably take more space on your hard-drive... but it worked at first try after :)

I hope it'll do for you too.

Bartabok avatar Mar 17 '25 10:03 Bartabok

replac \infer\lib\train\utils.py, line 238, line 239 with these codes

data = np.frombuffer(fig.canvas.buffer_rgba(), dtype=np.uint8) data = data.reshape((fig.canvas.get_width_height()[::-1] + (4,)))

add this code

data = data[..., :3]

plt.close()

it works for me (matplotlib=3.10.1, numpy=1.26.4)

BoringSoul avatar Mar 18 '25 06:03 BoringSoul