{"id":16881511,"url":"https://github.com/swhl/lgpma_infer","last_synced_at":"2025-07-23T15:05:17.550Z","repository":{"id":40391714,"uuid":"498304765","full_name":"SWHL/LGPMA_Infer","owner":"SWHL","description":"表格结构识别LGPMA推理","archived":false,"fork":false,"pushed_at":"2022-11-17T09:25:51.000Z","size":1695,"stargazers_count":23,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-27T21:41:16.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SWHL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-31T11:22:08.000Z","updated_at":"2025-04-01T05:49:28.000Z","dependencies_parsed_at":"2023-01-22T15:31:11.599Z","dependency_job_id":null,"html_url":"https://github.com/SWHL/LGPMA_Infer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SWHL/LGPMA_Infer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FLGPMA_Infer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FLGPMA_Infer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FLGPMA_Infer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FLGPMA_Infer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SWHL","download_url":"https://codeload.github.com/SWHL/LGPMA_Infer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FLGPMA_Infer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265002566,"owners_count":23696077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T16:02:59.330Z","updated_at":"2025-07-23T15:05:17.522Z","avatar_url":"https://github.com/SWHL.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## LGPMA_Infer\n- 整理自于: [DAVAR-Lab-OCR](https://github.com/hikopensource/DAVAR-Lab-OCR/tree/main/demo/table_recognition/lgpma)\n- 因为该模型都是基于英文表格训练而来，因此对于中文表格识别能力较差，但是也具有一定的适应能力。\n- 相关介绍博客：[论文阅读: （ICDAR2021 海康威视）LGPMA（表格识别算法）及官方源码对应解读](http://t.csdn.cn/aToa2)\n\n#### 模型下载\n- [pth (Access Code: zUoX)](https://one.hikvision.com/#/link/u9YgYyoPW3hLw6iolFoA) 177M ResNet50\n- 下载之后放到`models`目录下即可\n\n#### 环境搭建\n- `mmdet`: 该库不用安装，因为仓库中已经有了mmdet离线包，该包是下载的2.25.0，为了可以转onnx，里面做了一些修改，不影响现在的推理\n- 其他库安装：\n  ```shell\n  pip install -r requirements.txt -i https://pypi.douban.com/simple/\n  ```\n\n#### demo运行\n```shell\npython test_pub.py\n\n# 输出结果，会在output目录下保存绘制框线的图像\n# OK\n```\n- 结果示例：\n  - 原图：\n\n    ![](./images/table.jpg)\n\n  - 识别结果:\n\n     ![](./output/table.jpg)\n\n#### 模型转onnx\n- 状态：可以成功转换,转换时也特别耗费内存-_-!，同时因基于ONNXRuntime推理时，太耗费内存，而放弃\n- 转换脚本:\n  ```shell\n  bash model_2_onnx.sh\n  ```\n- 转换之后onnx模型下载[link](https://drive.google.com/file/d/1t2muqUFif-jbbTqQUrWGHjHZo3MgYxgQ/view?usp=sharing)，仅供参考，推理尚未成功\n- 验证推理代码：\n  ```python\n  # 在davarocr/davar_common/apis/inference.py#L119行插入\n  import onnxruntime\n  session = onnxruntime.InferenceSession('lgpma.onnx')\n  input_name = session.get_inputs()[0].name\n  inputs = {\n      input_name: data['img'][0].numpy().astype(np.float32)\n  }\n  outs = session.run(None, inputs)\n  ```\n\n#### 参考链接\n- [mmdet/pytorch2onnx](https://github.com/open-mmlab/mmdetection/blob/master/docs/en/tutorials/pytorch2onnx.md)\n- [ONNX and grid_sample layer](https://github.com/pytorch/pytorch/issues/27212)\n- [Pytorch转ONNX遇到的问题及解决方案](https://blog.csdn.net/JoeyChen1219/article/details/121141318)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswhl%2Flgpma_infer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswhl%2Flgpma_infer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswhl%2Flgpma_infer/lists"}