PaddleOCR中的SDMGR模型导出失败

4nkexdtk  于 4个月前  发布在  其他
关注(0)|答案(5)|浏览(123)

PaddleOCR中的SDMGR模型导出失败

(haobin_paddle_ocr_env) (base) [root@localhost PaddleOCR]# python3 tools/export_model.py -c output/kie_60/config.yml -o Architecture.Backbone.checkpoints=output/kie_60/best_accuracy
ERROR:albumentations.check_version:Error fetching version info
Traceback (most recent call last):
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/albumentations/check_version.py", line 32, in fetch_version_info
data = response.read()
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/http/client.py", line 472, in read
s = self._safe_read(self.length)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/http/client.py", line 613, in _safe_read
data = self.fp.read(amt)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/ssl.py", line 1274, in recv_into
return self.read(nbytes, buffer)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/ssl.py", line 1132, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
W0731 17:03:00.388967 42736 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.4, Runtime API Version: 11.8
W0731 17:03:00.390235 42736 gpu_resources.cc:164] device: 0, cuDNN Version: 8.9.
[2024/07/31 17:03:00] ppocr INFO: train from scratch
Traceback (most recent call last):
File "tools/export_model.py", line 300, in
main()
File "tools/export_model.py", line 294, in main
export_single_model(
File "tools/export_model.py", line 197, in export_single_model
paddle.jit.save(model, save_path)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/base/wrapped_decorator.py", line 26, in impl
return wrapped_func(*args, **kwargs)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/api.py", line 809, in wrapper
func(layer, path, input_spec, **configs)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/base/wrapped_decorator.py", line 26, in impl
return wrapped_func(*args, **kwargs)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/base/dygraph/base.py", line 68, in impl
return func(*args, **kwargs)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/api.py", line 1104, in save
static_func.concrete_program_specify_input_spec(
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/dy2static/program_translator.py", line 986, in concrete_program_specify_input_spec
concrete_program, _ = self.get_concrete_program(
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/dy2static/program_translator.py", line 875, in get_concrete_program
concrete_program, partial_program_layer = self._program_cache[
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/dy2static/program_translator.py", line 1648, in getitem
self._caches[item_id] = self._build_once(item)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/dy2static/program_translator.py", line 1575, in _build_once
concrete_program = ConcreteProgram.from_func_spec(
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/base/wrapped_decorator.py", line 26, in impl
return wrapped_func(*args, **kwargs)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/base/dygraph/base.py", line 68, in impl
return func(*args, **kwargs)
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/dy2static/program_translator.py", line 1346, in from_func_spec
error_data.raise_new_exception()
File "/root/anaconda3/envs/haobin_paddle_ocr_env/lib/python3.8/site-packages/paddle/jit/dy2static/error.py", line 452, in raise_new_exception
raise new_exception from None
AttributeError: In transformed code:

File "/haobin/code_repo/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 84, in forward
    if self.use_backbone:
File "/haobin/code_repo/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 85, in forward
    x = self.backbone(x)
File "/haobin/code_repo/PaddleOCR/ppocr/modeling/backbones/kie_unet_sdmgr.py", line 190, in forward
    img, relations, texts, gt_bboxes = self.pre_process(
File "/haobin/code_repo/PaddleOCR/ppocr/modeling/backbones/kie_unet_sdmgr.py", line 156, in pre_process
    def pre_process(self, img, relations, texts, gt_bboxes, tag, img_size):
        img, relations, texts, gt_bboxes, tag, img_size = (
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
            img.numpy(),
            relations.numpy(),

AttributeError: 'Variable' object has no attribute 'tolist'

(haobin_paddle_ocr_env) (base) [root@localhost PaddleOCR]#

其他补充信息 Additional Supplementary Information

使用的是CentOS 7.9
使用conda构建的python3.8
CUDA 12.4 cudnn 8.9
paddle使用的版本尝试了3.0 Beta和2.6.1

s4n0splo

s4n0splo1#

可以把这个 tolist 删除了试试呢?

t5zmwmid

t5zmwmid2#


可以把这个 tolist 删除了试试呢?

感谢你的回复,我尝试删除tolist进行训练并导出,出现了新的错误
`TypeError: In transformed code:

File "/haobin/code_repo/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 84, in forward
    if self.use_backbone:
File "/haobin/code_repo/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 85, in forward
    x = self.backbone(x)
File "/haobin/code_repo/PaddleOCR/ppocr/modeling/backbones/kie_unet_sdmgr.py", line 230, in forward
    img, relations, texts, gt_bboxes = self.pre_process(
File "/haobin/code_repo/PaddleOCR/ppocr/modeling/backbones/kie_unet_sdmgr.py", line 200, in pre_process
    temp_relations, temp_texts, temp_gt_bboxes = [], [], []
    h, w = int(np.max(img_size[:, 0])), int(np.max(img_size[:, 1]))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    img = paddle.to_tensor(img[:, :, :h, :w])
    print(tag)

File "<__array_function__ internals>", line 200, in amax

File "/root/anaconda3/envs/paddle_env/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2820, in amax
    return _wrapreduction(a, np.maximum, 'max', axis, None, out,
File "/root/anaconda3/envs/paddle_env/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
    return reduction(axis=axis, out=out, **passkwargs)

TypeError: max() got an unexpected keyword argument 'out'`
e1xvtsh3

e1xvtsh33#

np.max 是 numpy 的接口,这样的 代码是无法动转静的,可以尝试使用paddle 的接口重写一下。比如先转tensor再使用paddle.max

13z8s7eq

13z8s7eq4#

感谢你的回复,我按你的指导尝试修改了np.max,遇到了新的维度不匹配的问题,在训练过程中,打印出来的维度分别是4和2,但是在导出模型时,打印出的维度是3和3,请问这个问题如何解决?

2w3kk1z5

2w3kk1z55#

我看这个是模型刚开始就出现了diff,这个你得追溯一下最早出现diff的位置了。

相关问题