Skip to content

Commit

Permalink
docs: Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Jul 22, 2024
1 parent 408459c commit 097d607
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RapidTable是整理自PP-Structure中表格识别部分而来。由于PP-Structu

### 安装

由于模型较小,预先将英文表格识别模型(`en_ppstructure_mobile_v2_SLANet.onnx`)打包进了whl包内,如果做英文表格识别,可直接安装使用
由于模型较小,预先将英文表格识别模型(`en_ppstructure_mobile_v2_SLANet.onnx`)打包进了whl包内,如果做英文表格识别,可直接安装使用

> ⚠️注意:`rapid_table>=v0.1.0`之后,不再将`rapidocr_onnxruntime`依赖强制打包到`rapid_table`中。使用前,需要自行安装`rapidocr_onnxruntime`包。
Expand All @@ -53,56 +53,62 @@ pip install rapid_table

#### python脚本运行

````python
from pathlib import Path
RapidTable类提供model_path参数,可以自行指定上述2个模型,默认是`en_ppstructure_mobile_v2_SLANet.onnx`。举例如下:

from rapid_table import RapidTable
from rapid_table import RapidTable, VisTable
```python
table_engine = RapidTable(model_path='ch_ppstructure_mobile_v2_SLANet.onnx')
```

完整示例:

```python
from pathlib import Path

# RapidTable类提供model_path参数,可以自行指定上述2个模型,默认是en_ppstructure_mobile_v2_SLANet.onnx
# table_engine = RapidTable(model_path='ch_ppstructure_mobile_v2_SLANet.onnx')
table_engine = RapidTable()
ocr_engine = RapidOCR()
viser = VisTable()
from rapid_table import RapidTable
from rapid_table import RapidTable, VisTable

img_path = 'test_images/table.jpg'
table_engine = RapidTable()
ocr_engine = RapidOCR()
viser = VisTable()

ocr_result, _ = ocr_engine(img_path)
table_html_str, table_cell_bboxes, elapse = table_engine(img_path, ocr_result)
img_path = 'test_images/table.jpg'

save_dir = Path("./inference_results/")
save_dir.mkdir(parents=True, exist_ok=True)
ocr_result, _ = ocr_engine(img_path)
table_html_str, table_cell_bboxes, elapse = table_engine(img_path, ocr_result)

save_html_path = save_dir / f"{Path(img_path).stem}.html"
save_drawed_path = save_dir / f"vis_{Path(img_path).name}"
save_dir = Path("./inference_results/")
save_dir.mkdir(parents=True, exist_ok=True)

viser(img_path, table_html_str, save_html_path, table_cell_bboxes, save_drawed_path)
save_html_path = save_dir / f"{Path(img_path).stem}.html"
save_drawed_path = save_dir / f"vis_{Path(img_path).name}"

print(table_html_str)
````
viser(img_path, table_html_str, save_html_path, table_cell_bboxes, save_drawed_path)

print(table_html_str)
```

#### 终端运行

- 用法:

```bash
$ rapid_table -h
usage: rapid_table [-h] [-v] -img IMG_PATH [-m MODEL_PATH]
```bash
$ rapid_table -h
usage: rapid_table [-h] [-v] -img IMG_PATH [-m MODEL_PATH]

optional arguments:
-h, --help show this help message and exit
-v, --vis Whether 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.
```
optional arguments:
-h, --help show this help message and exit
-v, --vis Whether 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.
```

- 示例:

```bash
rapid_table -v -img test_images/table.jpg
```
```bash
rapid_table -v -img test_images/table.jpg
```

### 结果

Expand Down

0 comments on commit 097d607

Please sign in to comment.