Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Regarding the unsupported operand type error #42

Closed
TheIllusion opened this issue Jun 17, 2017 · 5 comments
Closed

Question: Regarding the unsupported operand type error #42

TheIllusion opened this issue Jun 17, 2017 · 5 comments

Comments

@TheIllusion
Copy link

TheIllusion commented Jun 17, 2017

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'

@kabrio
Copy link

kabrio commented Jun 17, 2017

maxbe you are not using the right version of torchvision?

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

@junyanz
Copy link
Owner

junyanz commented Jun 17, 2017

Thanks @kabrio. It should work.
To use our latest dataset loader, you need to install the latest PyTorch vision library.

git clone https://github.com/pytorch/vision
cd vision
python setup.py install

@TheIllusion
Copy link
Author

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

@aestebanlansaque
Copy link

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?

@junyanz
Copy link
Owner

junyanz commented Jul 11, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants