mingyuliutw / UNIT

Unsupervised Image-to-Image Translation
Other
1.98k stars 360 forks source link

RuntimeError in python3 #35

Closed CherylZR closed 6 years ago

CherylZR commented 6 years ago

Hi! Thank you very much for sharing your code. I encountered some error when training from scratch with celeba blond hair translation using python 3 according to the usage. The itertool.izip in python2 is changed to the built-in zip in python3:

Traceback (most recent call last): File "cocogan_train.py", line 88, in <module> main(sys.argv) File "cocogan_train.py", line 56, in main for it, (images_a, images_b) in enumerate(zip(train_loader_a,train_loader_b)): File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 301, in __iter__ return DataLoaderIter(self) File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 171, in __init__ self._put_indices() File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 210, in _put_indices indices = next(self.sample_iter, None) File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 115, in __iter__ for idx in self.sampler: File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 50, in __iter__ return iter(torch.randperm(len(self.data_source)).long()) RuntimeError: invalid argument 1: must be strictly positive at /opt/conda/conda-bld/pytorch_1503968623488/work/torch/lib/TH/generic/THTensorMath.c:2033 How can I fix this problem?

mingyuliutw commented 6 years ago

Please check Issue 17. https://github.com/mingyuliutw/UNIT/issues/17

benjaminlinken commented 6 years ago

@CherylZR I also met the same question. Have you solved it?

benjaminlinken commented 6 years ago

@mingyuliutw Hi! I don't quite understand what you mean. Does Issue 17 have anything to do with this issue?

CherylZR commented 6 years ago

@benjaminlinken I rewrote the dataloader in python 3 and solved it.

benjaminlinken commented 6 years ago

@CherylZR Can you tell me how you rewrote the dataloader?

CherylZR commented 6 years ago

@benjaminlinken it's very simple by just setting the right dataset, sample mode, etc. you can refer to the official document

benjaminlinken commented 6 years ago

@CherylZR Can you please tell me more details? I really don't know how to rewrote the dataloader.

benjaminlinken commented 6 years ago

@CherylZR Or you can send the modified files to my email, my email is 1278217355@qq.com. Thank you for your help!