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

AttributeError: 'bool' object has no attribute 'sum' when use_gpu: False #12132

Open
ltbd78 opened this issue May 16, 2024 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@ltbd78
Copy link

ltbd78 commented May 16, 2024

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:Python 3.12

  • 版本号/Version

    • Paddle:2.6.1
    • PaddleOCR:2.7.3
    • PaddleNLP: 2.6.1 (also tried 2.8.0, 2.5.x, 2.7.x)
  • 问题相关组件/Related components:
    Note only two changes differ:

    • in configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml, use_gpu: False
    • in configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml, use_gpu: False
  • 运行指令/Command Code:

python3 ./tools/infer_kie_token_ser_re.py \
  -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml \
  -o Architecture.Backbone.checkpoints=./pretrained_model/re_vi_layoutxlm_xfund_pretrained/best_accuracy \
  Global.infer_img=./test_data/passport_card_1.jpg \
  -c_ser configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml \
  -o_ser Architecture.Backbone.checkpoints=./pretrained_model/ser_vi_layoutxlm_xfund_pretrained/best_accuracy
  • 完整报错/Complete Error Message:
I0516 16:45:36.134816 55311040 kernel_dispatch.h:102] Get BackendSet from tensor
Traceback (most recent call last):
  File "/Users/linsuhan/Documents/GitHub/PaddleOCR/./tools/infer_kie_token_ser_re.py", line 216, in <module>
    result = ser_re_engine(data)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/PaddleOCR/./tools/infer_kie_token_ser_re.py", line 151, in __call__
    preds = self.model(re_input)
            ^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__
    return self.forward(*inputs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 85, in forward
    x = self.backbone(x)
        ^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__
    return self.forward(*inputs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/PaddleOCR/ppocr/modeling/backbones/vqa_layoutlm.py", line 248, in forward
    x = self.model(
        ^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__
    return self.forward(*inputs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1329, in forward
    loss, pred_relations = self.extractor(sequence_output, entities, relations)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__
    return self.forward(*inputs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1223, in forward
    relations, entities = self.build_relation(relations, entities)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/linsuhan/Documents/GitHub/paddle/.venv/lib/python3.12/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1189, in build_relation
    if negative_mask.sum() > 0:
       ^^^^^^^^^^^^^^^^^
AttributeError: 'bool' object has no attribute 'sum'
@GreatV GreatV added the bug Something isn't working label May 20, 2024
@zhangyubo0722
Copy link
Collaborator

可以评估一下验证集精度,看看是不是精度比较低,感觉像是没推理出来内容

@564142183
Copy link

564142183 commented May 31, 2024

指标评估命令

python3 tools/eval.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=./output/ser_vi_layoutxlm_xfund_zh/best_accuracy

image

你好,这个问题有解决吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants