TypeError: Cannot handle this data type: (1, 1, 389), |u1问题已解决

问题

Traceback (most recent call last):
File “runner.py”, line 93, in
main()
File “runner.py”, line 74, in main
train_net(cfg)
File “/home/mist/Pix2Vox-master/core/train.py”, line 264, in train_net
iou = test_net(cfg, epoch_idx + 1, output_dir, val_data_loader, val_writer, encoder, decoder, refiner, merger)
File “/home/mist/Pix2Vox-master/core/test.py”, line 152, in test_net
test_writer.add_image(‘Test Sample#%02d/Volume Reconstructed’ % sample_idx, rendering_views, epoch_idx)
File “/mistgpu/site-packages/tensorboardX/writer.py”, line 667, in add_image
image(tag, img_tensor, dataformats=dataformats), global_step, walltime)
File “/mistgpu/site-packages/tensorboardX/summary.py”, line 288, in image
image = make_image(tensor, rescale=rescale)
File “/mistgpu/site-packages/tensorboardX/summary.py”, line 328, in make_image
image = Image.fromarray(tensor)
File “/mistgpu/site-packages/PIL/Image.py”, line 2774, in fromarray
raise TypeError(“Cannot handle this data type: %s, %s” % typekey) from e
TypeError: Cannot handle this data type: (1, 1, 389), |u1

解决

依次修改以下文件:
/mistgpu/site-packages/tensorboardX/summary.py中
def image(tag, tensor, rescale=1, dataformats=‘HWC’)的入口参数’CHW’修改为‘HWC’;
/mistgpu/site-packages/tensorboardX/writer.py中的
def add_image(
self,
tag: str,
img_tensor: numpy_compatible,
global_step: Optional[int] = None,
walltime: Optional[float] = None,
dataformats: Optional[str] = ‘HWC’)
中的’CHW’修改为‘HWC’;
即可运行正常,具体原因见https://blog.csdn.net/weixin_40740309/article/details/114701132

在修改过程中可能会遇到只能修改只读文件,在Linux系统中,可以利用chmod 777 filename指令,修改文件权限。

查找文件地点
添加链接描述

你可能感兴趣的:(深度学习,pytorch,神经网络)