From b62cae50f524f297d24cbad0abbe5e63245a24fe Mon Sep 17 00:00:00 2001 From: SWHL Date: Wed, 19 Jun 2024 09:22:29 +0800 Subject: [PATCH] fix(rapid_layout): Fixed setup configuration --- docs/README_Layout.md | 25 +++++++------- docs/doc_whl_rapid_layout.md | 63 +----------------------------------- rapid_layout/main.py | 1 + setup_layout.py | 6 ++-- 4 files changed, 18 insertions(+), 77 deletions(-) diff --git a/docs/README_Layout.md b/docs/README_Layout.md index dac789f..bd2b518 100644 --- a/docs/README_Layout.md +++ b/docs/README_Layout.md @@ -46,18 +46,21 @@ $ pip install rapid-layout 2. 终端运行 - 用法: - ```bash - $ rapid_layout -h - usage: rapid_layout [-h] [-v] -img IMG_PATH [-m MODEL_PATH] + ```bash + $ rapid_layout -h + usage: rapid_layout [-h] -img IMG_PATH [-m {pp_layout_cdla,pp_layout_publaynet,pp_layout_table}] + [--box_threshold {pp_layout_cdla,pp_layout_publaynet,pp_layout_table}] [-v] - optional arguments: - -h, --help show this help message and exit - -v, --vis Wheter to visualize the layout results. - -img IMG_PATH, --img_path IMG_PATH - Path to image for layout. - -m MODEL_PATH, --model_path MODEL_PATH - The model path used for inference. - ``` + options: + -h, --help show this help message and exit + -img IMG_PATH, --img_path IMG_PATH + Path to image for layout. + -m {pp_layout_cdla,pp_layout_publaynet,pp_layout_table}, --model_type {pp_layout_cdla,pp_layout_publaynet,pp_layout_table} + Support model type + --box_threshold {pp_layout_cdla,pp_layout_publaynet,pp_layout_table} + Box threshold, the range is [0, 1] + -v, --vis Wheter to visualize the layout results. + ``` - 示例: ```bash $ rapid_layout -v -img test_images/layout.png diff --git a/docs/doc_whl_rapid_layout.md b/docs/doc_whl_rapid_layout.md index a953e18..8163c11 100644 --- a/docs/doc_whl_rapid_layout.md +++ b/docs/doc_whl_rapid_layout.md @@ -1,62 +1 @@ -## rapid-layout -

- - - PyPI - -

- - -### 1. Install package by pypi. -```bash -$ pip install rapid-layout -``` - -### 2. Run by script. -- RapidLayout has the default `model_path` value, you can set the different value of `model_path` to use different models, e.g. `layout_engine = RapidLayout(model_path='layout_publaynet.onnx')` -- See details, for [README_Layout](https://github.com/RapidAI/RapidStructure/blob/main/docs/README_Layout.md) . -- 📌 `layout.png` source: [link](https://github.com/RapidAI/RapidStructure/blob/main/test_images/layout.png) - -```python -from rapid_layout import RapidLayout - -layout_engine = RapidLayout() - -with open('layout.png', 'rb') as f: - img = f.read() - -layout_res, elapse = layout_engine(img) -print(layout_res) -``` - -### 3. Run by command line. -- Usage: - ```bash - $ rapid_layout -h - usage: rapid_layout [-h] [-v] -img IMG_PATH [-m MODEL_PATH] - - optional arguments: - -h, --help show this help message and exit - -v, --vis Wheter to visualize the layout results. - -img IMG_PATH, --img_path IMG_PATH - Path to image for layout. - -m MODEL_PATH, --model_path MODEL_PATH - The model path used for inference. - ``` -- Example: - ```bash - $ rapid_layout -v -img layout.png - ``` - -### 4. Result. -- Return value. - ```python - [ - {'bbox': array([321.4160495, 91.53214898, 562.06141263, 199.85522603]), 'label': 'text'}, - {'bbox': array([58.67292211, 107.29000663, 300.25448676, 199.68142]), 'label': 'table_caption'} - ] - ``` -- Visualize result. -
- -
+See [link](https://github.com/RapidAI/RapidStructure) for details. diff --git a/rapid_layout/main.py b/rapid_layout/main.py index d5f292d..ae06b92 100644 --- a/rapid_layout/main.py +++ b/rapid_layout/main.py @@ -150,6 +150,7 @@ def main(): if ploted_img is not None: save_path = img_path.resolve().parent / f"vis_{img_path.name}" cv2.imwrite(str(save_path), ploted_img) + print(f"The visualized image has been saved in {save_path}") if __name__ == "__main__": diff --git a/setup_layout.py b/setup_layout.py index 902a85b..79cbe83 100644 --- a/setup_layout.py +++ b/setup_layout.py @@ -47,7 +47,7 @@ def get_readme(): "numpy>=1.21.6,<2", "Pillow", ], - packages=[MODULE_NAME, f"{MODULE_NAME}.models"], + packages=[MODULE_NAME, f"{MODULE_NAME}.models", f"{MODULE_NAME}.utils"], package_data={"": ["layout_cdla.onnx", "*.yaml"]}, keywords=["ppstructure,layout,rapidocr,rapid_layout"], classifiers=[ @@ -60,7 +60,5 @@ def get_readme(): "Programming Language :: Python :: 3.12", ], python_requires=">=3.6,<3.13", - entry_points={ - "console_scripts": [f"{MODULE_NAME}={MODULE_NAME}.{MODULE_NAME}:main"] - }, + entry_points={"console_scripts": [f"{MODULE_NAME}={MODULE_NAME}.main:main"]}, )