PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.28k stars 5.61k forks source link

使用表格识别模型进行推理时,导出模型出现了Each dimension size given in out_shape must be greater than 0错误 #68721

Open c61811 opened 1 month ago

c61811 commented 1 month ago

请提出你的问题 Please ask your question

使用表格识别模型进行推理时,导出模型出现了如下错误: [2024/10/15 16:42:15] ppocr INFO: resume from output-2/SLANet_ch/latest feat_low shape size: (-1, -1) Traceback (most recent call last): File "/home/tsy-3kfpf86/OCR/PaddleOCR/tools/export_model.py", line 37, in main() File "/home/tsy-3kfpf86/OCR/PaddleOCR/tools/export_model.py", line 33, in main export(config) File "/home/tsy-3kfpf86/OCR/PaddleOCR/ppocr/utils/export_model.py", line 379, in export export_single_model( File "/home/tsy-3kfpf86/OCR/PaddleOCR/ppocr/utils/export_model.py", line 269, in export_single_model paddle.jit.save(model, save_path) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/jit.py", line 631, in wrapper func(layer, path, input_spec, configs) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), *kw) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(args, kwargs) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/base.py", line 51, in impl return func(*args, kwargs) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/jit.py", line 860, in save concrete_program = static_func.concrete_program_specify_input_spec( File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 527, in concrete_program_specify_input_spec concreteprogram, = self.get_concrete_program( File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 436, in get_concrete_program concrete_program, partial_program_layer = self._program_cache[cache_key] File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 801, in getitem self._caches[item_id] = self._build_once(item) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 785, in _build_once concrete_program = ConcreteProgram.from_func_spec( File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), *kw) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(args, kwargs) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/base.py", line 51, in impl return func(*args, **kwargs) File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 740, in from_func_spec error_data.raise_new_exception() File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/fluid/dygraph/dygraph_to_static/error.py", line 336, in raise_newexception six.exec("raise new_exception from None") File "", line 1, in AssertionError: In transformed code:

File "/home/tsy-3kfpf86/OCR/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 92, in forward
    x = self.neck(x)
File "/home/tsy-3kfpf86/OCR/PaddleOCR/ppocr/modeling/necks/csp_pan.py", line 321, in forward
    print(f"feat_low shape size: {feat_low.shape[2:4]}")

    upsample_feat = F.upsample(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
        feat_heigh, size=feat_low.shape[2:4], mode="nearest"
    )

File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/nn/functional/common.py", line 689, in upsample
    return interpolate(x, size, scale_factor, mode, align_corners, align_mode,
File "/home/tsy-3kfpf86/.local/lib/python3.9/site-packages/paddle/nn/functional/common.py", line 378, in interpolate
    assert dim_size > 0, (

AssertionError: Each dimension size given in out_shape must be greater than 0.
cuicheng01 commented 1 month ago

您好,请详细说明下PaddleOCR和Paddle的版本

c61811 commented 1 month ago

您好,请详细说明下PaddleOCR和Paddle的版本

涉及的主要软件版本: ubuntu 18.04 cuda 10.2 cudnn 8 paddle 1.0.2 paddle-bfloat 0.1.7 paddleocr 2.8.1 paddlepaddle 2.4.2 paddlepaddle-gpu 2.3.2

c61811 commented 1 month ago

您好,请详细说明下PaddleOCR和Paddle的版本

请帮忙看看这个问题如何解决了?在搜索引擎中都找不到对应的解决方案

c61811 commented 1 month ago

eval model:: 100%|██████████████████████████████████████████████████████████████eval model:: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 42/42 [00:37<00:00, 1.11it/s] [2024/10/17 14:07:13] ppocr INFO: metric eval *** [2024/10/17 14:07:13] ppocr INFO: acc:0.97849999951075 [2024/10/17 14:07:13] ppocr INFO: fps:64.43237163262431 model eval是可以的,为什么到了export_model就不行了呢,难道就没有别人遇到过这个问题吗?

c61811 commented 1 month ago

您好,请详细说明下PaddleOCR和Paddle的版本

请安排人员帮忙看看这个问题呀,关键是在搜索引擎里面也找不到相应的类似问题

c61811 commented 1 month ago

您好,请详细说明下PaddleOCR和Paddle的版本

涉及的主要软件版本: ubuntu 18.04 cuda 10.2 cudnn 8 paddle 1.0.2 paddle-bfloat 0.1.7 paddleocr 2.8.1 paddlepaddle 2.4.2 paddlepaddle-gpu 2.3.2

解决了,里面多安装了一个paddle 1.0.2的依赖,执行pip uninstall paddle就可以了

c61811 commented 1 month ago

补充一下,后来这个问题又出现了,应该是版本之间不兼容导致的,升级到如下版本后解决: paddlepaddle-gpu==2.6.1 paddleocr[gpu]==2.9.0

经过多次尝试,发现ubuntu 18.04、cuda 10.2、cudnn 8这个环境下最新的兼容版本是 paddlepaddle-gpu==2.4.2 paddleocr[gpu]==2.8.1 paddlepaddle低于2.4.2都会出现上面的问题