-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
186 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,6 @@ xlrd==2.0.1 | |
uvicorn | ||
fastapi | ||
orjson | ||
|
||
# client | ||
tritonclient[http]==2.41.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
## models endpoint for idp sdk | ||
|
||
- ocr model endpoint: http://{host:port}/v2/idp/idp_app/infer | ||
- layout model endpoint: http://{host:port}/v2/models/elem_layout_v1/infer | ||
- table det model endpoint: http://{host:port}/v2/models/elem_table_detect_v1/infer | ||
- table rowcol model endpoint: http://{host:port}/v2/models/elem_table_rowcol_detect_v1/infer | ||
- table cell model endpoint: http://{host:port}/v2/models/elem_table_cell_detect_v1/infer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# flake8: noqa | ||
import base64 | ||
import hashlib | ||
import json | ||
import os | ||
|
||
import pytest | ||
|
||
from bisheng_unstructured.models.layout_agent import LayoutAgent | ||
from bisheng_unstructured.models.ocr_agent import OCRAgent | ||
from bisheng_unstructured.models.table_agent import TableAgent, TableDetAgent | ||
|
||
configs = dict( | ||
layout_ep="http://192.168.106.20:10502/v2/models/elem_layout_v1/infer", | ||
cell_model_ep="http://192.168.106.20:10502/v2/models/elem_table_cell_detect_v1/infer", | ||
rowcol_model_ep="http://192.168.106.20:10502/v2/models/elem_table_rowcol_detect_v1/infer", | ||
table_model_ep="http://192.168.106.20:10502/v2/models/elem_table_detect_v1/infer", | ||
ocr_model_ep="http://192.168.106.20:10502/v2/idp/idp_app/infer", | ||
) | ||
|
||
|
||
# @pytest.mark.skip | ||
def test_layout(): | ||
layout_agent = LayoutAgent(**configs) | ||
|
||
image_file = "data/001.png" | ||
b64_image = base64.b64encode(open(image_file, "rb").read()).decode("utf-8") | ||
inp = {"b64_image": b64_image} | ||
result = layout_agent.predict(inp) | ||
print("result", result) | ||
|
||
|
||
# @pytest.mark.skip | ||
def test_ocr(): | ||
ocr_agent = OCRAgent(**configs) | ||
|
||
image_file = "data/001.png" | ||
b64_image = base64.b64encode(open(image_file, "rb").read()).decode("utf-8") | ||
inp = {"b64_image": b64_image} | ||
result = ocr_agent.predict(inp) | ||
print("result", result) | ||
|
||
|
||
def test_table_det(): | ||
table_det_agent = TableDetAgent(**configs) | ||
table_agent = TableAgent(**configs) | ||
ocr_agent = OCRAgent(**configs) | ||
|
||
image_file = "data/001.png" | ||
b64_image = base64.b64encode(open(image_file, "rb").read()).decode("utf-8") | ||
inp = {"b64_image": b64_image} | ||
table_bboxes = table_det_agent.predict(inp)["bboxes"] | ||
ocr_result = json.dumps(ocr_agent.predict(inp)["result"]["ocr_result"]) | ||
inp = {"b64_image": b64_image, "table_bboxes": table_bboxes, "ocr_result": ocr_result} | ||
table_result = table_agent.predict(inp) | ||
print("table_result", table_result) |