Speech-enhancement icon indicating copy to clipboard operation
Speech-enhancement copied to clipboard

TypeError: Cannot handle this data type

Open hlkang2380 opened this issue 6 years ago • 5 comments

hello, I have a problem and want to ask a question. I started main.py without modifying the code, but I got an error. I need advice on where to fix it.

Thank you

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2428, in fromarray mode, rawmode = _fromarray_typemap[typekey] KeyError: ((1, 1, 129), '|u1')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/khl/Desktop/prj_dir/SE/main.py", line 89, in tr.main([prj_dir, logs_dir]) File "./lib/train.py", line 353, in main train_summary.do_summary(m_valid, sess, eng, writer, itr) File "./lib/train.py", line 161, in do_summary writer.add_image(name + '_spectrogram_ref' + '/clean', clean_S, itr) # image_shape = (C, H, W) File "/usr/local/lib/python3.6/dist-packages/tensorboardX/writer.py", line 427, in add_image image(tag, img_tensor, dataformats=dataformats), global_step, walltime) File "/usr/local/lib/python3.6/dist-packages/tensorboardX/summary.py", line 216, in image image = make_image(tensor, rescale=rescale) File "/usr/local/lib/python3.6/dist-packages/tensorboardX/summary.py", line 254, in make_image image = Image.fromarray(tensor) File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2431, in fromarray raise TypeError("Cannot handle this data type") TypeError: Cannot handle this data type

hlkang2380 avatar Mar 22 '19 03:03 hlkang2380

Hello, I had the same issue and I used np.transpose() to solve it. You're going to need to use it for all mentions of writer.add_image().

writer.add_image(name + '_spectrogram_ref' + '/clean', np.transpose(clean_S), itr) writer.add_image(name + '_spectrogram_ref' + '/noisy', np.transpose(noisy_S), itr).

I Hope this helps!

HAEKADI avatar Mar 22 '19 17:03 HAEKADI

Thank you for your reply. I figure out that that error is from version difference of TensorboardX. I'll fix that part, soon.

jtkim-kaist avatar Mar 27 '19 01:03 jtkim-kaist

Dear,

How to set the validation set ? Please help me. Thx

ucasiggcas avatar Jun 18 '19 03:06 ucasiggcas

and writer.add_image(name + '_spectrogram_enhanced' + '/enhanced', enhanced_S, itr) # image_shape = (C, H, W) in the same py file also need np.transpose ?

I will try both.

ucasiggcas avatar Jun 21 '19 06:06 ucasiggcas

just modify the two writer.add_image(name + '_spectrogram_ref' + '/clean', np.transpose(clean_S), itr) # image_shape = (C, H, W) writer.add_image(name + '_spectrogram_ref' + '/noisy', np.transpose(noisy_S), itr) # image_shape = (C, H, W) also has the same question

I will try the second modify all the three writer.add_image writer.add_image(name + '_spectrogram_enhanced' + '/enhanced', np.transpose(enhanced_S), itr) # image_shape = (C, H, W)

ucasiggcas avatar Jun 22 '19 05:06 ucasiggcas