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

Help! TypeError: an integer is required (got type tuple) #184

Open
cy998412 opened this issue Sep 8, 2021 · 5 comments
Open

Help! TypeError: an integer is required (got type tuple) #184

cy998412 opened this issue Sep 8, 2021 · 5 comments

Comments

@cy998412
Copy link

cy998412 commented Sep 8, 2021

wenwu@Amax:~ /chenyao/awesome-semantic-segmentation-pytorch-master/scripts$ python train.py --model fcn32s --backbone vgg16 --dataset pascal_voc --lr 0.0001 --epochs 50
2021-09-08 18:06:48,524 semantic_segmentation INFO: Using 1 GPUs
2021-09-08 18:06:48,524 semantic_segmentation INFO: Namespace(aux=False, aux_weight=0.4, backbone='vgg16', base_size=520, batch_size=4, crop_size=480, dataset='pascal_voc', device='cuda', distributed=False, epochs=50, jpu=False, local_rank=0, log_dir='../runs/logs/', log_iter=10, lr=0.0001, model='fcn32s', momentum=0.9, no_cuda=False, num_gpus=1, resume=None, save_dir='~/.torch/models', save_epoch=10, skip_val=False, start_epoch=0, use_ohem=False, val_epoch=1, warmup_factor=0.3333333333333333, warmup_iters=0, warmup_method='linear', weight_decay=0.0001, workers=4)
Found 1464 images in the folder /data1/chenyao/datasets/VOC2012
Found 1449 images in the folder /data1/chenyao/datasets/VOC2012
2021-09-08 18:06:53,200 semantic_segmentation INFO: Start training, Total Epochs: 50 = Total Iterations 18300
Traceback (most recent call last):
File "train.py", line 323, in
trainer.train()
File "train.py", line 210, in train
for iteration, (images, targets, _) in enumerate(self.train_loader):
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in next
data = self._next_data()
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
return self._process_data(data)
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
data.reraise()
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/_utils.py", line 394, in reraise
raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/wenwu/chenyao/awesome-semantic-segmentation-pytorch-master/core/data/dataloader/pascal_voc.py", line 82, in getitem
img, mask = self._sync_transform(img, mask)
File "/home/wenwu/chenyao/awesome-semantic-segmentation-pytorch-master/core/data/dataloader/segbase.py", line 66, in _sync_transform
mask = ImageOps.expand(mask, border=(0, 0, padw, padh), fill=0)
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/ImageOps.py", line 403, in expand
draw.rectangle((0, 0, width - 1, height - 1), outline=color, width=border)
File "/home/wenwu/anaconda3/envs/detectron/lib/python3.7/site-packages/PIL/ImageDraw.py", line 259, in rectangle
self.draw.draw_rectangle(xy, ink, 0, width)
TypeError: an integer is required (got type tuple)

@Tramac
Copy link
Owner

Tramac commented Sep 16, 2021

Please check the input of this line.

@yyotta
Copy link

yyotta commented Sep 17, 2021

There might be something wrong with the version of pillow. Try this : border=(0, 0, padw, padh) -> border=20

@cy998412
Copy link
Author

There might be something wrong with the version of pillow. Try this : border=(0, 0, padw, padh) -> border=20

Thank you very much, I solved it.
But I don't know why "img = ImageOps.expand(img, border=(0, 0, padw, padh), fill=0)" can run
but "mask = ImageOps.expand(mask, border=(0, 0, padw, padh), fill=0)" can not?

@xjsxujingsong
Copy link

@cy998412 how to solve this problem?

@chenshihao2002
Copy link

@cy998412 How did you solve this problem?

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

5 participants