yiranran / APDrawingGAN

Code for APDrawingGAN: Generating Artistic Portrait Drawings from Face Photos with Hierarchical GANs (CVPR 2019 Oral)
Apache License 2.0
788 stars 147 forks source link

How to solve this TypeError: only integer tensors of a single element can be converted to an index #19

Closed ChauvinisticJonatha closed 2 years ago

ChauvinisticJonatha commented 3 years ago

File "F:\compare_cartoon\APDrawingGAN-master\data\aligned_dataset.py", line 146, in getitem item[regions[i]+'_A'] = A[:,center[i,1]-rhs[i]/2:center[i,1]+rhs[i]/2,center[i,0]-rws[i]/2:center[i,0]+rws[i]/2] TypeError: only integer tensors of a single element can be converted to an index [Network DLEyer] Total number of parameters : 2.767 M [Network DLNose] Total number of parameters : 2.767 M [Network DLMouth] Total number of parameters : 2.767 M [Network DLHair] Total number of parameters : 2.767 M [Network DLBG] Total number of parameters : 2.767 M [Network GLEyel] Total number of parameters : 1.448 M [Network GLEyer] Total number of parameters : 1.448 M [Network GLNose] Total number of parameters : 1.448 M [Network GLMouth] Total number of parameters : 1.448 M [Network GLHair] Total number of parameters : 1.710 M [Network GLBG] Total number of parameters : 1.710 M [Network GCombine] Total number of parameters : 0.158 M

Setting up a new session... create web directory ./checkpoints/formal/web... Traceback (most recent call last): File "train.py", line 25, in for i, data in enumerate(dataset): File "/data/zzj/APDrawingGAN-master/data/init.py", line 72, in iter for i, data in enumerate(self.dataloader): File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next return self._process_next_batch(batch) File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch raise batch.exc_type(batch.exc_msg) TypeError: Traceback (most recent call last): File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/data/zzj/APDrawingGAN-master/data/aligned_dataset.py", line 146, in getitem item[regions[i]+'_A'] = A[:,center[i,1]-rhs[i]/2:center[i,1]+rhs[i]/2,center[i,0]-rws[i]/2:center[i,0]+rws[i]/2] TypeError: only integer tensors of a single element can be converted to an index

yiranran commented 3 years ago

Sorry, this error is because the original version is run using python2 Please check can this commit solve your problem? https://github.com/yiranran/APDrawingGAN/commit/bc10583a244620325c6e4874566112ebbf5d2c7d

ChauvinisticJonatha commented 3 years ago

Thank you very much, I have made it solved. Thank you.