-
-
Notifications
You must be signed in to change notification settings - Fork 41
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 #87 from RapidAI/optim_wired_table_rotated
feat: optim rotated wired table rec
- Loading branch information
Showing
6 changed files
with
206 additions
and
31 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
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,7 +1,7 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
from typing import Any, Dict, Optional | ||
from typing import Any, Dict, Optional, Tuple | ||
|
||
import cv2 | ||
import numpy as np | ||
|
@@ -36,12 +36,14 @@ def __init__(self, model_path: Optional[str] = None): | |
|
||
self.session = OrtInferSession(model_path) | ||
|
||
def __call__(self, img: np.ndarray, **kwargs) -> Optional[np.ndarray]: | ||
def __call__( | ||
self, img: np.ndarray, **kwargs | ||
) -> Tuple[Optional[np.ndarray], Optional[np.ndarray]]: | ||
img_info = self.preprocess(img) | ||
pred = self.infer(img_info) | ||
polygons = self.postprocess(pred) | ||
if polygons.size == 0: | ||
return None | ||
return None, None | ||
|
||
polygons = polygons.reshape(polygons.shape[0], 4, 2) | ||
del_idxs = filter_duplicated_box( | ||
|
@@ -53,7 +55,7 @@ def __call__(self, img: np.ndarray, **kwargs) -> Optional[np.ndarray]: | |
) | ||
polygons = polygons[idx] | ||
polygons = merge_adjacent_polys(polygons) | ||
return polygons | ||
return polygons, polygons | ||
|
||
def preprocess(self, img) -> Dict[str, Any]: | ||
height, width = img.shape[:2] | ||
|
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
Oops, something went wrong.