{"id":18273593,"url":"https://github.com/rapidai/rapidtabledetection","last_synced_at":"2025-04-05T02:31:20.108Z","repository":{"id":258587687,"uuid":"872360332","full_name":"RapidAI/RapidTableDetection","owner":"RapidAI","description":"检测和提取各种场景图片中的表格区域，并纠正透视和旋转问题    Detect and extract table regions from images in various scenarios, and correct perspective and rotation issues.","archived":false,"fork":false,"pushed_at":"2024-12-10T01:28:02.000Z","size":8297,"stargazers_count":74,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T04:03:52.143Z","etag":null,"topics":["onnxruntime","table","table-detection","table-structure"],"latest_commit_sha":null,"homepage":"","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/RapidAI.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-14T09:55:38.000Z","updated_at":"2025-03-31T13:44:13.000Z","dependencies_parsed_at":"2024-10-20T14:47:23.643Z","dependency_job_id":null,"html_url":"https://github.com/RapidAI/RapidTableDetection","commit_stats":null,"previous_names":["joker1212/rapidtabledetection"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidTableDetection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidTableDetection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidTableDetection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidTableDetection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RapidAI","download_url":"https://codeload.github.com/RapidAI/RapidTableDetection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247279429,"owners_count":20912882,"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":["onnxruntime","table","table-detection","table-structure"],"created_at":"2024-11-05T12:06:59.688Z","updated_at":"2025-04-05T02:31:20.054Z","avatar_url":"https://github.com/RapidAI.png","language":"Python","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003ch1\u003e\u003cb\u003e📊RapidTableDetection\u003c/b\u003e\u003c/h1\u003e\n  \u003c/div\u003e\n  \u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/Python-\u003e=3.8,\u003c3.12-aff.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/OS-Linux%2C%20Mac%2C%20Win-pink.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://semver.org/\"\u003e\u003cimg alt=\"SemVer2.0\" src=\"https://img.shields.io/badge/SemVer-2.0-brightgreen\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/RapidAI/TableStructureRec/blob/c41bbd23898cb27a957ed962b0ffee3c74dfeff1/LICENSE\"\u003e\u003cimg alt=\"GitHub\" src=\"https://img.shields.io/badge/license-Apache 2.0-blue\"\u003e\u003c/a\u003e\n\n[English](README_en.md) | 简体中文\n\u003c/div\u003e\n\n### 最近更新\n\n- **2024.10.15**\n    - 完成初版代码，包含目标检测，语义分割，角点方向识别三个模块\n- **2024.11.2**\n    - 补充新训练yolo11的目标检测模型和边缘检测模型\n    - 增加自动下载，轻量化包体积\n    - 补充onnx-gpu推理支持，给出benchmark测试结果\n    - 补充在线示例使用\n\n### 简介\n\n💡✨ 强大且高效的表格检测，支持论文、期刊、杂志、发票、收据、签到单等各种表格。\n\n🚀 支持来源于paddle和yolo的版本，默认模型组合单图 CPU 推理仅需 1.2 秒，onnx-GPU(V100) 最小组合仅需 0.4 秒,paddle-gpu版0.2s\n🛠️ 支持三个模块自由组合，独立训练调优，提供 ONNX 转换脚本和微调训练方案。\n\n🌟 whl 包轻松集成使用，为下游 OCR、表格识别和数据采集提供强力支撑。\n\n📚参考项目 [百度表格检测大赛第2名方案](https://aistudio.baidu.com/projectdetail/5398861?searchKeyword=%E8%A1%A8%E6%A0%BC%E6%A3%80%E6%B5%8B%E5%A4%A7%E8%B5%9B\u0026searchTab=ALL)\n的实现方案，补充大量真实场景数据再训练\n![img.png](readme_resource/structure.png)\n👇🏻训练数据集在致谢, 作者天天上班摸鱼搞开源，希望大家点个⭐️支持一下\n\n### 使用建议\n\n📚 文档场景: 无透视旋转，只使用目标检测\\\n📷 拍照场景小角度旋转(-90~90): 默认左上角，不使用角点方向识别\\\n🔍 使用在线体验找到适合你场景的模型组合\n\n### 在线体验\n[modelscope](https://www.modelscope.cn/studios/jockerK/RapidTableDetDemo) [huggingface](https://huggingface.co/spaces/Joker1212/RapidTableDetection)\n### 效果展示\n\n![res_show.jpg](readme_resource/res_show.jpg)![res_show2.jpg](readme_resource/res_show2.jpg)\n\n### 安装\n\n🪜模型会自动下载，也可以自己去仓库下载 [modescope模型仓](https://www.modelscope.cn/models/jockerK/TableExtractor)\n\n``` python {linenos=table}\n# 建议使用清华源安装 https://pypi.tuna.tsinghua.edu.cn/simple\npip install rapid-table-det\n```\n\n#### 参数说明\n\n默认值\nuse_cuda: False : 启用gpu加速推理 \\\nobj_model_type=\"yolo_obj_det\", \\\nedge_model_type= \"yolo_edge_det\", \\\ncls_model_type= \"paddle_cls_det\"\n\n由于onnx使用gpu加速效果有限，还是建议直接使用yolox或安装paddle来执行模型会快很多(有需要我再补充整体流程)\npaddle的s模型由于量化导致反而速度降低和精度降低，但是模型大小减少很多\n\n| `model_type`         | 任务类型   | 训练来源                                 | 大小     | 单表格耗时(v100-16G,cuda12,cudnn9,ubuntu) |\n|:---------------------|:-------|:-------------------------------------|:-------|:-------------------------------------|\n| **yolo_obj_det**     | 表格目标检测 | `yolo11-l`                           | `100m` | `cpu:570ms, gpu:400ms`               |\n| `paddle_obj_det`     | 表格目标检测 | `paddle yoloe-plus-x`                | `380m` | `cpu:1000ms, gpu:300ms`              |\n| `paddle_obj_det_s`   | 表格目标检测 | `paddle yoloe-plus-x + quantization` | `95m`  | `cpu:1200ms, gpu:1000ms`             |\n| **yolo_edge_det**    | 语义分割   | `yolo11-l-segment`                   | `108m` | `cpu:570ms, gpu:200ms`               |\n| `yolo_edge_det_s`    | 语义分割   | `yolo11-s-segment`                   | `11m`  | `cpu:260ms, gpu:200ms`               |\n| `paddle_edge_det`    | 语义分割   | `paddle-dbnet`                       | `99m`  | `cpu:1200ms, gpu:120ms`              |\n| `paddle_edge_det_s`  | 语义分割   | `paddle-dbnet + quantization`        | `25m`  | `cpu:860ms, gpu:760ms`               |\n| **paddle_cls_det**     | 方向分类   | `paddle pplcnet`                     | `6.5m` | `cpu:70ms, gpu:60ms`                 |\n\n\n执行参数\ndet_accuracy=0.7,\nuse_obj_det=True,\nuse_edge_det=True,\nuse_cls_det=True,\n\n### 快速使用\n\n``` python {linenos=table}\nfrom rapid_table_det.inference import TableDetector\n\nimg_path = f\"tests/test_files/chip.jpg\"\ntable_det = TableDetector()\n\nresult, elapse = table_det(img_path)\nobj_det_elapse, edge_elapse, rotate_det_elapse = elapse\nprint(\n    f\"obj_det_elapse:{obj_det_elapse}, edge_elapse={edge_elapse}, rotate_det_elapse={rotate_det_elapse}\"\n)\n# 输出可视化\n# import os\n# import cv2\n# from rapid_table_det.utils.visuallize import img_loader, visuallize, extract_table_img\n# \n# img = img_loader(img_path)\n# img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n# file_name_with_ext = os.path.basename(img_path)\n# file_name, file_ext = os.path.splitext(file_name_with_ext)\n# out_dir = \"rapid_table_det/outputs\"\n# if not os.path.exists(out_dir):\n#     os.makedirs(out_dir)\n# extract_img = img.copy()\n# for i, res in enumerate(result):\n#     box = res[\"box\"]\n#     lt, rt, rb, lb = res[\"lt\"], res[\"rt\"], res[\"rb\"], res[\"lb\"]\n#     # 带识别框和左上角方向位置\n#     img = visuallize(img, box, lt, rt, rb, lb)\n#     # 透视变换提取表格图片\n#     wrapped_img = extract_table_img(extract_img.copy(), lt, rt, rb, lb)\n#     cv2.imwrite(f\"{out_dir}/{file_name}-extract-{i}.jpg\", wrapped_img)\n# cv2.imwrite(f\"{out_dir}/{file_name}-visualize.jpg\", img)\n\n```\n### paddle版本使用\n必须下载模型，指定模型位置！\n``` python {linenos=table}\n# 建议使用清华源安装 https://pypi.tuna.tsinghua.edu.cn/simple\npip install rapid-table-det-paddle (默认安装gpu版本，可以自行覆盖安装cpu版本paddlepaddle)\n```\n```python\nfrom rapid_table_det_paddle.inference import TableDetector\n\nimg_path = f\"tests/test_files/chip.jpg\"\n\ntable_det = TableDetector(\n    obj_model_path=\"models/obj_det_paddle\",\n    edge_model_path=\"models/edge_det_paddle\",\n    cls_model_path=\"models/cls_det_paddle\",\n    use_obj_det=True,\n    use_edge_det=True,\n    use_cls_det=True,\n)\nresult, elapse = table_det(img_path)\nobj_det_elapse, edge_elapse, rotate_det_elapse = elapse\nprint(\n    f\"obj_det_elapse:{obj_det_elapse}, edge_elapse={edge_elapse}, rotate_det_elapse={rotate_det_elapse}\"\n)\n# 一张图片中可能有多个表格\n# img = img_loader(img_path)\n# file_name_with_ext = os.path.basename(img_path)\n# file_name, file_ext = os.path.splitext(file_name_with_ext)\n# out_dir = \"rapid_table_det_paddle/outputs\"\n# if not os.path.exists(out_dir):\n#     os.makedirs(out_dir)\n# extract_img = img.copy()\n# for i, res in enumerate(result):\n#     box = res[\"box\"]\n#     lt, rt, rb, lb = res[\"lt\"], res[\"rt\"], res[\"rb\"], res[\"lb\"]\n#     # 带识别框和左上角方向位置\n#     img = visuallize(img, box, lt, rt, rb, lb)\n#     # 透视变换提取表格图片\n#     wrapped_img = extract_table_img(extract_img.copy(), lt, rt, rb, lb)\n#     cv2.imwrite(f\"{out_dir}/{file_name}-extract-{i}.jpg\", wrapped_img)\n# cv2.imwrite(f\"{out_dir}/{file_name}-visualize.jpg\", img)\n\n```\n\n## FAQ (Frequently Asked Questions)\n\n1. **问：如何微调模型适应特定场景?**\n   - 答：直接参考这个项目，有非常详细的可视化操作步骤,数据集也在里面，可以得到paddle的推理模型 [百度表格检测大赛](https://aistudio.baidu.com/projectdetail/5398861?searchKeyword=%E8%A1%A8%E6%A0%BC%E6%A3%80%E6%B5%8B%E5%A4%A7%E8%B5%9B\u0026searchTab=ALL),\n   - yolo11的训练使用官方脚本足够简单，按官方指导转换为coco格式训练即可\n2. **问：如何导出onnx**\n    - 答：paddle模型需要在本项目tools下，有onnx_transform.ipynb文件\n      yolo11的话，直接参照官方的方式一行搞定  \n3. **问：图片有扭曲可以修正吗？**\n    - 答：本项目只解决旋转和透视场景的表格提取，对于扭曲的场景，需要先进行扭曲修正\n\n### 致谢\n\n[百度表格检测大赛第2名方案](https://aistudio.baidu.com/projectdetail/5398861?searchKeyword=%E8%A1%A8%E6%A0%BC%E6%A3%80%E6%B5%8B%E5%A4%A7%E8%B5%9B\u0026searchTab=ALL) \\\n[WTW 自然场景表格数据集](https://tianchi.aliyun.com/dataset/108587) \\\n[FinTabNet PDF文档表格数据集](https://developer.ibm.com/exchanges/data/all/fintabnet/) \\\n[TableBank 表格数据集](https://doc-analysis.github.io/tablebank-page/) \\\n[TableGeneration 表格自动生成工具](https://github.com/WenmuZhou/TableGeneration)\n\n### 贡献指南\n\n欢迎提交请求。对于重大更改，请先打开issue讨论您想要改变的内容。\n\n有其他的好建议和集成场景，作者也会积极响应支持\n\n### 开源许可证\n\n该项目采用[Apache 2.0](https://github.com/RapidAI/TableStructureRec/blob/c41bbd23898cb27a957ed962b0ffee3c74dfeff1/LICENSE)\n开源许可证。\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidai%2Frapidtabledetection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidai%2Frapidtabledetection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidai%2Frapidtabledetection/lists"}