opconty / pytorch_ctpn

This is a pytorch implementation of CTPN(Detecting Text in Natural Image with Connectionist Text Proposal Network). You may want to finetune from: https://drive.google.com/open?id=1JHhI4sEIXfs5gDa1I9AgJBY477HTzAd0
https://mp.weixin.qq.com/s/VO42GzwwJBOabpPJOWVn4g
291 stars 123 forks source link

ctpn_train batch=1 change to 128 get error #3

Closed zhuchangjiang closed 5 years ago

zhuchangjiang commented 5 years ago

device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') checkpoints_weight = args['pretrained_weights'] if os.path.exists(checkpoints_weight): pretrained = False

dataset = VOCDataset(args['image_dir'], args['labels_dir'])
dataloader = DataLoader(dataset, batch_size=**128**, shuffle=True, num_workers=args['num_workers'])
model = CTPN_Model()
model.to(device)

Traceback (most recent call last): File "ctpn_train.py", line 91, in for batch_i, (imgs, clss, regrs) in enumerate(dataloader): File "/home/zhanglijun/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 637, in next return self._process_next_batch(batch) File "/home/zhanglijun/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch raise batch.exc_type(batch.exc_msg) RuntimeError: Traceback (most recent call last): File "/home/zhanglijun/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/zhanglijun/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 232, in default_collate return [default_collate(samples) for samples in transposed] File "/home/zhanglijun/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 232, in return [default_collate(samples) for samples in transposed] File "/home/zhanglijun/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 209, in default_collate return torch.stack(batch, 0, out=out) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 562 and 600 in dimension 2 at /pytorch/aten/src/TH/generic/THTensorMoreMath.cpp:1333

fxwispig commented 5 years ago

这个只能使用batch_size为1

opconty commented 5 years ago

sorry for late reply just as @fxwispig said, thanks

unanan commented 4 years ago

想问一下 bs=1能训的动吗?