TypeError:Cannot handle this data type
@albertpumarola Hi, I make my own database and want to train the model. I use this to train:python train.py --data_dir /media/xirui/XIRUI/database1 --name try3 --batch_size 25 But during it , I found this problem:
------------ Options -------------
D_adam_b1: 0.5
D_adam_b2: 0.999
G_adam_b1: 0.5
G_adam_b2: 0.999
aus_file: aus_openface.pkl
batch_size: 25
checkpoints_dir: ./checkpoints
cond_nc: 17
data_dir: /media/xirui/XIRUI/database1
dataset_mode: aus
display_freq_s: 300
do_saturate_mask: False
gpu_ids: [0]
image_size: 128
images_folder: imgs
is_train: True
lambda_D_cond: 4000
lambda_D_gp: 10
lambda_D_prob: 1
lambda_cyc: 10
lambda_mask: 0.1
lambda_mask_smooth: 1e-05
load_epoch: 0
lr_D: 0.0001
lr_G: 0.0001
model: ganimation
n_threads_test: 1
n_threads_train: 4
name: try3
nepochs_decay: 10
nepochs_no_decay: 20
num_iters_validate: 1
poses_g_sigma: 0.06
print_freq_s: 60
save_latest_freq_s: 3600
serial_batches: False
test_ids_file: test_ids.csv
train_G_every_n_iterations: 5
train_ids_file: train_ids.csv
-------------- End ----------------
./checkpoints/try3
Dataset AusDataset was created
Dataset AusDataset was created
#train images = 478
#test images = 479
Network generator_wasserstein_gan was created
Network discriminator_wasserstein_gan was created
Model GANimation was created
/home/xirui/XIr/GANimation-master/models/ganimation.py:320: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_mskd_fake', self._loss_g_masked_fake.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:321: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_mskd_cond', self._loss_g_masked_cond.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:322: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_cyc', self._loss_g_cyc.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:326: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_m1', self._loss_g_mask_1.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:327: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_m2', self._loss_g_mask_2.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:328: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_m1_s', self._loss_g_mask_1_smooth.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:329: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('g_m2_s', self._loss_g_mask_2_smooth.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:331: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('d_real', self._loss_d_real.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:332: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('d_cond', self._loss_d_cond.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:333: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('d_fake', self._loss_d_fake.data[0]),
/home/xirui/XIr/GANimation-master/models/ganimation.py:334: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
('d_gp', self._loss_d_gp.data[0])])
[30/09/2018 17:14:19] (Tv, epoch: 1, it: 0/19, t/smpl: 0.039s) g_fake:0.000 g_cond:0.000 g_mskd_fake:0.025 g_mskd_cond:1.769 g_cyc:4.888 g_rgb:0.000 g_rgb_un:0.000 g_rgb_s:0.000 g_m1:0.046 g_m2:0.046 g_m1_s:0.742 g_m2_s:0.753 g_idt:0.000 d_real:0.013 d_cond:1.705 d_fake:-0.009 d_gp:7.552
Traceback (most recent call last):
File "train.py", line 141, in
I've checked the pic in my database and they're both 3 channels and 128*128. And I've tried some database with different number and I found that when the number of pic is more than 48, this problem would occur, while the process of training was right when the number of pic is less than 48
Is there someone who can help me? Thanks!!
In this line: File "/home/xirui/XIr/GANimation-master/utils/tb_visualizer.py", line 27, in display_current_results self._writer.add_image(sum_name, image_numpy, it)self._writer.add_image(sum_name, image_numpy, it) I changed the image_numpy in to tensor and normalized it between 0 to 1 which solved the problem
@Blade6570 Hi, I also met the same problem. I changed the image_numpy into a tensor by using 'torch.from_numpy(image_numpy).div(255)' but still got stuck. Would you mind share your code with me?
Many thanks.
@yanxirui Hi yanxirui, I met the same problem as you, may I know whether you have solved the problem?
Not only covert it to tensor but convert to actual format (CXWXH) as follows: I=torch.from_numpy(image_numpy).permute(2,0,1) self._writer.add_image(sum_name, I/255, it)
@Blade6570 I see, I replaced 'image_numpy' by 'np.transpose(image_numpy,(2,0,1))' and solved the problem. Thank you very much.
@yanxirui Hi yanxirui, I met the same problem as you, may I know whether you have solved the problem?
I find do_visuals may has no effect on the train itself so I made do_visuals = 0 before.... And I use the method @Blade6570 mentioned to solve this problem successfully. Thanks to him.
Seems this is a versions error. You are probably using Pytorch 0.4, this code was made previous to this version release. It was made for Pytorch 0.3.1.
@albertpumarola I have try pytorch 0.3.1,but it encounter a error in "display visualizer". Then I modified ganimation.py in Iine-346 def get_current_visuals(self): , and add "np.transpose(image_numpy,(2,0,1))" after numpy of OrderedDict()。
OR self._writer.add_image(sum_name, np.transpose(image_numpy,(2,0,1)), it) In "utils/tb_visualizer.py "...
I think it is caused by Different versions of tensorboardX ,not by the pytorch version。
I think you should use tensorboard 1.8
BTW, can you provide a docker file about the running environment? it's really helpful
Use tensorboardX version-1.1. It looks like it works.