我想要识别的文本比较长,所以想尝试将max_text_length设置为一个更大的数,但是改变该值后(默认为25,修改成50后),训练报错:
Traceback (most recent call last):
File "PaddleOCR/tools/train.py", line 208, in <module>
main(config, device, logger, vdl_writer)
File "PaddleOCR/tools/train.py", line 180, in main
program.train(config, train_dataloader, valid_dataloader, device, model,
File "/home/data/experiment/ocr/text/PaddleOCR/tools/program.py", line 294, in train
preds = model(images)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/parallel.py", line 774, in forward
outputs = self._layers(*inputs, **kwargs)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/data/experiment/ocr/text/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 100, in forward
x = self.head(x, targets=data)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/data/experiment/ocr/text/PaddleOCR/ppocr/modeling/heads/rec_abinet_head.py", line 228, in forward
v_feature, attn_scores = self.decoder(
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/data/experiment/ocr/text/PaddleOCR/ppocr/modeling/heads/rec_abinet_head.py", line 169, in forward
attn_vecs = attn_scores @v # (B, N, C)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/math_op_patch.py", line 298, in __impl__
return math_op(self, other_var, False, False)
ValueError: (InvalidArgument) Input(Y) has error dim.Y'dims[1] must be equal to 256But received Y'dims[1] is 160
[Hint: Expected y_dims[y_ndim - 2] == K, but received y_dims[y_ndim - 2]:160 != K:256.] (at /paddle/paddle/phi/kernels/impl/matmul_kernel_impl.h:314)
gpu131:248326:248326 [2] NCCL INFO comm 0x36a21810 rank 0 nranks 2 cudaDev 2 busId b1000 - Destroy COMPLETE
I0803 13:48:13.335893 248399 tcp_store.cc:257] receive shutdown event and so quit from MasterDaemon run loop
LAUNCH INFO 2023-08-03 13:48:15,249 Exit code 1
图片大小默认的也不符合要求,修改后(默认为[3, 32, 128]修改为[3, 32, 512])也会报错:
Traceback (most recent call last):
File "PaddleOCR/tools/train.py", line 208, in <module>
main(config, device, logger, vdl_writer)
File "PaddleOCR/tools/train.py", line 180, in main
program.train(config, train_dataloader, valid_dataloader, device, model,
File "/home/data/experiment/ocr/text/PaddleOCR/tools/program.py", line 294, in train
preds = model(images)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/parallel.py", line 774, in forward
outputs = self._layers(*inputs, **kwargs)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/data/experiment/ocr/text/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 100, in forward
x = self.head(x, targets=data)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/data/experiment/ocr/text/PaddleOCR/ppocr/modeling/heads/rec_abinet_head.py", line 224, in forward
feature = self.pos_encoder(feature)
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 948, in __call__
return self.forward(*inputs, **kwargs)
File "/home/data/experiment/ocr/text/PaddleOCR/ppocr/modeling/heads/rec_nrtr_head.py", line 500, in forward
x = x + self.pe[:paddle.shape(x)[0], :]
File "/home/opt/anaconda3/envs/doc-ocr/lib/python3.8/site-packages/paddle/fluid/dygraph/math_op_patch.py", line 304, in __impl__
return math_op(self, other_var, -1)
ValueError: (InvalidArgument) Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [1024, 16, 512] and the shape of Y = [256, 1, 512]. Received [1024] in X is not equal to [256] in Y at i:0.
[Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] (at /paddle/paddle/phi/kernels/funcs/common_shape.h:84)
gpu131:250597:250597 [2] NCCL INFO comm 0x3864b5a0 rank 0 nranks 2 cudaDev 2 busId b1000 - Destroy COMPLETE
I0803 13:56:35.494895 250668 tcp_store.cc:257] receive shutdown event and so quit from MasterDaemon run loop
LAUNCH INFO 2023-08-03 13:56:38,031 Exit code 1