-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RapidAI/adapt_yolo_model
Adapt yolo model
- Loading branch information
Showing
14 changed files
with
930 additions
and
561 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
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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
from rapid_table_det.inference import TableDetector | ||
|
||
img_path = f"tests/test_files/chip2.jpg" | ||
img_path = f"images/weixin.png" | ||
table_det = TableDetector( | ||
obj_model_path="rapid_table_det/models/obj_det.onnx", | ||
edge_model_path="rapid_table_det/models/edge_det.onnx", | ||
obj_model_type="paddle_obj_det_s", edge_model_type="paddle_edge_det_s" | ||
) | ||
|
||
result, elapse = table_det(img_path) | ||
obj_det_elapse, edge_elapse, rotate_det_elapse = elapse | ||
print( | ||
f"obj_det_elapse:{obj_det_elapse}, edge_elapse={edge_elapse}, rotate_det_elapse={rotate_det_elapse}" | ||
) | ||
# 输出可视化 | ||
import os | ||
import cv2 | ||
from rapid_table_det.utils import img_loader, visuallize, extract_table_img | ||
|
||
img = img_loader(img_path) | ||
file_name_with_ext = os.path.basename(img_path) | ||
file_name, file_ext = os.path.splitext(file_name_with_ext) | ||
out_dir = "rapid_table_det/outputs" | ||
if not os.path.exists(out_dir): | ||
os.makedirs(out_dir) | ||
extract_img = img.copy() | ||
for i, res in enumerate(result): | ||
box = res["box"] | ||
lt, rt, rb, lb = res["lt"], res["rt"], res["rb"], res["lb"] | ||
# 带识别框和左上角方向位置 | ||
img = visuallize(img, box, lt, rt, rb, lb) | ||
# 透视变换提取表格图片 | ||
wrapped_img = extract_table_img(extract_img.copy(), lt, rt, rb, lb) | ||
cv2.imwrite(f"{out_dir}/{file_name}-extract-{i}.jpg", wrapped_img) | ||
cv2.imwrite(f"{out_dir}/{file_name}-visualize.jpg", img) | ||
# import os | ||
# import cv2 | ||
# from rapid_table_det.utils.visuallize import img_loader, visuallize, extract_table_img | ||
# | ||
# img = img_loader(img_path) | ||
# file_name_with_ext = os.path.basename(img_path) | ||
# file_name, file_ext = os.path.splitext(file_name_with_ext) | ||
# out_dir = "rapid_table_det/outputs" | ||
# if not os.path.exists(out_dir): | ||
# os.makedirs(out_dir) | ||
# extract_img = img.copy() | ||
# for i, res in enumerate(result): | ||
# box = res["box"] | ||
# lt, rt, rb, lb = res["lt"], res["rt"], res["rb"], res["lb"] | ||
# # 带识别框和左上角方向位置 | ||
# img = visuallize(img, box, lt, rt, rb, lb) | ||
# # 透视变换提取表格图片 | ||
# wrapped_img = extract_table_img(extract_img.copy(), lt, rt, rb, lb) | ||
# cv2.imwrite(f"{out_dir}/{file_name}-extract-{i}.jpg", wrapped_img) | ||
# cv2.imwrite(f"{out_dir}/{file_name}-visualize.jpg", img) |
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 |
---|---|---|
|
@@ -2,7 +2,3 @@ | |
# @Author: Jocker1212 | ||
# @Contact: [email protected] | ||
from .inference import TableDetector | ||
from .utils import img_loader, visuallize, extract_table_img | ||
|
||
# | ||
__all__ = ["TableDetector", "img_loader", "visuallize", "extract_table_img"] |
Oops, something went wrong.