|
@@ -20,7 +20,6 @@ import paddleclas
|
|
|
from cores.post_hander import *
|
|
|
from cores.check_table import *
|
|
|
|
|
|
-
|
|
|
format_print()
|
|
|
|
|
|
# 初始化APP
|
|
@@ -35,7 +34,6 @@ app.add_middleware(
|
|
|
allow_headers=["*"],
|
|
|
)
|
|
|
|
|
|
-
|
|
|
table_engine_lock = threading.Lock()
|
|
|
|
|
|
table_engine = PPStructure(layout=False,
|
|
@@ -43,15 +41,16 @@ table_engine = PPStructure(layout=False,
|
|
|
use_gpu=True,
|
|
|
show_log=True,
|
|
|
use_angle_cls=True,
|
|
|
- # det_model_dir="models/det/det_table_v2",
|
|
|
- # det_model_dir="models/det/det_table_v3",
|
|
|
- # rec_model_dir="models/rec/rec_table_v1",
|
|
|
+ # det_model_dir="models/det/det_table_v2",
|
|
|
+ # det_model_dir="models/det/det_table_v3",
|
|
|
+ # rec_model_dir="models/rec/rec_table_v1",
|
|
|
table_model_dir="models/table/SLANet_911")
|
|
|
|
|
|
-
|
|
|
cls_lock = threading.Lock()
|
|
|
|
|
|
cls_model = paddleclas.PaddleClas(model_name="text_image_orientation")
|
|
|
+
|
|
|
+
|
|
|
# # 普通表格
|
|
|
# table_engine = PPStructure(layout=False,
|
|
|
# table=True,
|
|
@@ -102,7 +101,6 @@ def cal_html_to_chs(html):
|
|
|
return len(rec_res)
|
|
|
|
|
|
|
|
|
-
|
|
|
def predict_cls(image, conf=0.8):
|
|
|
try:
|
|
|
cls_lock.acquire()
|
|
@@ -146,6 +144,7 @@ def get_zero_degree_image(img):
|
|
|
continue
|
|
|
return img
|
|
|
|
|
|
+
|
|
|
def table_res(im, ROTATE=-1):
|
|
|
im = im.copy()
|
|
|
# cv2.imwrite('before-rotate.jpg', im)
|
|
@@ -160,6 +159,7 @@ def table_res(im, ROTATE=-1):
|
|
|
html = res[0]['res']['html']
|
|
|
return res, html
|
|
|
|
|
|
+
|
|
|
class TableInfo(BaseModel):
|
|
|
image: str
|
|
|
det: str
|
|
@@ -176,11 +176,10 @@ def table(image: TableInfo):
|
|
|
img = base64_to_np(image.image)
|
|
|
res, html = table_res(img)
|
|
|
# print(html)
|
|
|
- table = Table(html,img)
|
|
|
+ table = Table(html, img)
|
|
|
if table.check_html():
|
|
|
res, html = table_res(table.img)
|
|
|
|
|
|
-
|
|
|
if html:
|
|
|
post_hander = PostHandler(html)
|
|
|
# print(post_hander.format_predict_html)
|