ecnuycxie / DG-Font

The pytorch implementation of DG-Font: Deformable Generative Networks for Unsupervised Font Generation
216 stars 45 forks source link

error occur in validation #11

Closed zhangfengyo closed 3 years ago

zhangfengyo commented 3 years ago

Traceback (most recent call last): File "main.py", line 400, in main() File "main.py", line 170, in main main_worker(args.gpu, ngpus_per_node, args) File "main.py", line 250, in main_worker validationFunc(val_loader, networks, epoch, args, {'logger': logger}) File "/content/drive/My Drive/DG-Font-main/validation/validation.py", line 82, in validateUN x_res_ematmp, = G_EMA.decode(c_src, s_ref, skip1, skip2) File "/content/drive/My Drive/DG-Font-main/models/generator.py", line 51, in decode out = self.decoder(cnt, skip1, skip2) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, kwargs) File "/content/drive/My Drive/DG-Font-main/models/generator.py", line 87, in forward output = self.modeli File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/content/drive/My Drive/DG-Font-main/models/blocks.py", line 15, in forward return self.model(x) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py", line 139, in forward input = module(input) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, kwargs) File "/content/drive/My Drive/DG-Font-main/models/blocks.py", line 32, in forward residual = self.model(x) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py", line 139, in forward input = module(input) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, kwargs) File "/content/drive/My Drive/DG-Font-main/models/blocks.py", line 158, in forward x = self.norm(x) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/content/drive/My Drive/DG-Font-main/models/blocks.py", line 208, in forward True, self.momentum, self.eps) File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 2282, in batch_norm input, weight, bias, running_mean, running_var, training, momentum, eps, torch.backends.cudnn.enabled RuntimeError: weight should contain 512 elements not 2560

ecnuycxie commented 3 years ago

It seems that the channel dimension is wrong. What's the size of your training images?

zhangfengyo commented 3 years ago

160,will it be wrong?

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年7月26日(星期一) 中午11:37 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ecnuycxie/DG-Font] error occur in validation (#11)

It seems that the channel dimension is wrong. What's the size of your training images?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

zhangfengyo commented 3 years ago

START EPOCH[1] SAVE CHECKPOINT[1] DONE train 0% 0/1000 [00:00<?, ?it/s]/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.) return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode) 10% 99/1000 [00:37<05:23, 2.78it/s]Epoch: [1/25] [100/1000] MODE[GAN] Avg Loss: D[5.74] G[0.91] 20% 199/1000 [01:13<04:48, 2.77it/s]Epoch: [1/25] [200/1000] MODE[GAN] Avg Loss: D[3.84] G[1.00] 30% 299/1000 [01:49<04:11, 2.78it/s]Epoch: [1/25] [300/1000] MODE[GAN] Avg Loss: D[3.22] G[0.87] 40% 399/1000 [02:25<03:35, 2.79it/s]Epoch: [1/25] [400/1000] MODE[GAN] Avg Loss: D[3.01] G[0.73] 50% 499/1000 [03:01<02:59, 2.79it/s]Epoch: [1/25] [500/1000] MODE[GAN] Avg Loss: D[2.82] G[0.67] 60% 599/1000 [03:37<02:23, 2.79it/s]Epoch: [1/25] [600/1000] MODE[GAN] Avg Loss: D[2.72] G[0.62] 70% 699/1000 [04:13<01:47, 2.79it/s]Epoch: [1/25] [700/1000] MODE[GAN] Avg Loss: D[2.68] G[0.57] 80% 799/1000 [04:49<01:12, 2.78it/s]Epoch: [1/25] [800/1000] MODE[GAN] Avg Loss: D[2.63] G[0.60] 90% 899/1000 [05:25<00:36, 2.79it/s]Epoch: [1/25] [900/1000] MODE[GAN] Avg Loss: D[2.62] G[0.55] 100% 999/1000 [06:01<00:00, 2.77it/s]Epoch: [1/25] [1000/1000] MODE[GAN] Avg Loss: D[2.56] G[0.52] 100% 1000/1000 [06:01<00:00, 2.77it/s] validation START EPOCH[2] SAVE CHECKPOINT[2] DONE train [W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool) [W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool) [W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool) [W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool) 10% 99/1000 [00:35<05:23, 2.78it/s]Epoch: [2/25] [100/1000] MODE[GAN_EMA] Avg Loss: D[2.27] G[-0.24] 20% 199/1000 [01:11<04:49, 2.77it/s]Epoch: [2/25] [200/1000] MODE[GAN_EMA] Avg Loss: D[2.16] G[0.04] 30% 299/1000 [01:48<04:13, 2.76it/s]Epoch: [2/25] [300/1000] MODE[GAN_EMA] Avg Loss: D[2.23] G[-0.13] 40% 399/1000 [02:23<03:36, 2.77it/s]Epoch: [2/25] [400/1000] MODE[GAN_EMA] Avg Loss: D[2.17] G[-0.01] 50% 499/1000 [03:00<03:00, 2.78it/s]Epoch: [2/25] [500/1000] MODE[GAN_EMA] Avg Loss: D[2.13] G[0.03] 60% 599/1000 [03:35<02:24, 2.78it/s]Epoch: [2/25] [600/1000] MODE[GAN_EMA] Avg Loss: D[2.15] G[0.11] 70% 699/1000 [04:11<01:47, 2.79it/s]Epoch: [2/25] [700/1000] MODE[GAN_EMA] Avg Loss: D[2.12] G[0.13] 80% 799/1000 [04:47<01:12, 2.79it/s]Epoch: [2/25] [800/1000] MODE[GAN_EMA] Avg Loss: D[2.10] G[0.17] 90% 899/1000 [05:23<00:36, 2.78it/s]Epoch: [2/25] [900/1000] MODE[GAN_EMA] Avg Loss: D[2.10] G[0.20] 100% 999/1000 [05:59<00:00, 2.79it/s]Epoch: [2/25] [1000/1000] MODE[GAN_EMA] Avg Loss: D[2.09] G[0.21] 100% 1000/1000 [06:00<00:00, 2.78it/s] validation Traceback (most recent call last): File "main.py", line 400, in main() File "main.py", line 170, in main main_worker(args.gpu, ngpus_per_node, args) File "main.py", line 250, in main_worker validationFunc(val_loader, networks, epoch, args, {'logger': logger}) File "/content/drive/MyDrive/DG-Font-main/validation/validation.py", line 74, in validateUN x_ref = x_each_cls[ref_idx][:args.val_batch, :, :, :].cuda(args.gpu, non_blocking=True) TypeError: 'NoneType' object is not subscriptable

zhangfengyo commented 3 years ago

it is hard to know the reason behind it

ecnuycxie commented 3 years ago

The original code is only for 80*80. If you want to utilize different resolutions of images, you'd better increase convolution layers in the content encoder and the mixer. Besides, Checking the initialization of each network and the size of each feature map will help you resolve your questions.

Outerskyb commented 3 years ago

You should change args.att_to_use match with num_cls change main.py:192 to args.att_to_use = [i for i in range(args.num_cls)]

for me it worked

zhangfengyo commented 3 years ago

You should change args.att_to_use match with num_cls change main.py:192 to args.att_to_use = [i for i in range(args.num_cls)]

for me it worked

Yes, i have find it was the reason behind

zj916716524 commented 1 year ago

for me it worked I modified args.att_to_use = [i for i in range(args.num_cls)], but after the second epoch the network fell into the effect of stopping motionless, and the graphics card resources are being occupied.

You should change args.att_to_use match with num_cls change main.py:192 to args.att_to_use = [i for i in range(args.num_cls)]

for me it worked

I modified args.att_to_use = [i for i in range(args.num_cls)], but after the second epoch the network fell into the effect of stopping motionless, and the graphics card resources are being occupied.

haooxia commented 1 year ago

At this point, The code has entered the validation stage. During the validation process, it is required to save num_fonts * num_fonts * 2 images. So if there is no information being printed for a long time, it means that images are being continuously saved.

This can be seen here: https://github.com/ecnuycxie/DG-Font/blob/b9368fd2527a42714742786a47d3bff08b8a96c8/validation/validation.py#L65-L69