Pytorch-cyclegan-and-pix2pix: Question: Regarding the unsupported operand type error

Created on 17 Jun 2017  路  5Comments  路  Source: junyanz/pytorch-CycleGAN-and-pix2pix

Hi.
I've been using the torch based CycleGAN and Pix2pix code for a while and I think it's a great work.
The paper is also astonishing.

Now I want to move to the PyTorch based CycleGan/Pix2pix code.
But I have an error in my environment.

My environment is
-Ubuntu 14.04
-Python 2.7
-CUDA 8

and the error message is attached below.

As far as I remember the PyTorch based code worked OK in my environment.
I guess this problem might be caused by my environment settings and it might be fixed easily.
But I don't have any clue to fix this.

Could you give any tips for this issue?

< Error message>

### python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan

...
...
...
model [CycleGANModel] was created
create web directory ./checkpoints/maps_cyclegan/web...
Traceback (most recent call last):
File "train.py", line 20, in
for i, data in enumerate(dataset):
File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 212, in __next__
return self._process_next_batch(batch)
File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 239, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
TypeError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 41, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/media/illusion/ML_DATA_SSD_M550/pytorch-CycleGAN-and-pix2pix/data/unaligned_dataset.py", line 46, in __getitem__
A_img = self.transform(A_img)
File "/usr/local/lib/python2.7/dist-packages/torchvision/transforms.py", line 29, in __call__
img = t(img)
File "/usr/local/lib/python2.7/dist-packages/torchvision/transforms.py", line 139, in __call__
ow = int(self.size * w / h)

TypeError: unsupported operand type(s) for /: 'list' and 'int'

All 5 comments

maxbe you are not using the right version of torchvision?

try pip install https://github.com/pytorch/vision/archive/master.zip --upgrade

Thanks @kabrio. It should work.
To use our latest dataset loader, you need to install the latest PyTorch vision library.
bash git clone https://github.com/pytorch/vision cd vision python setup.py install

Thanks @kabrio and @junyanz.
Great. It works!

I have the same problem but i got this message when I tried to download pyTorch:

pip install http://download.pytorch.org/whl/cu80/torch-0.1.12.post2-cp27-none-linux_x86_64.whl --user
Requirement already satisfied: torch==0.1.12.post2 from http://download.pytorch.org/whl/cu80/torch-0.1.12.post2-cp27-none-linux_x86_64.whl in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pyyaml in /usr/local/lib/python2.7/dist-packages (from torch==0.1.12.post2)

It looks like I have the last pyTorch version but Is till get the same error. Did you guys soleved just by installing the last pyTorch version?

You need to install the latest torch vision library from the source.

git clone https://github.com/pytorch/vision
cd vision
python setup.py install
Was this page helpful?
0 / 5 - 0 ratings

Related issues

shivom9713 picture shivom9713  路  4Comments

filmo picture filmo  路  3Comments

diaosiji picture diaosiji  路  3Comments

khryang picture khryang  路  3Comments

JamesChenChina picture JamesChenChina  路  3Comments