Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linknet hyperparameters postprocessing + demo for rotation model #865

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: linknet parameters
  • Loading branch information
charlesmindee committed Mar 16, 2022
commit ddec3a80e76f826c888254f988b6fbab763d439a
7 changes: 3 additions & 4 deletions doctr/models/detection/linknet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LinkNetPostProcessor(DetectionPostProcessor):
"""
def __init__(
self,
bin_thresh: float = 0.5,
bin_thresh: float = 0.1,
charlesmindee marked this conversation as resolved.
Show resolved Hide resolved
box_thresh: float = 0.1,
assume_straight_pages: bool = True,
) -> None:
Expand All @@ -39,7 +39,7 @@ def __init__(
bin_thresh,
assume_straight_pages
)
self.unclip_ratio = 1.5
self.unclip_ratio = 1.2

def polygon_to_box(
self,
Expand Down Expand Up @@ -103,13 +103,12 @@ def bitmap_to_boxes(
containing x, y, w, h, alpha, score for the box
"""
height, width = bitmap.shape[:2]
min_size_box = 1 + int(height / 512)
boxes = []
# get contours from connected components on the bitmap
contours, _ = cv2.findContours(bitmap.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
# Check whether smallest enclosing bounding box is not too small
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < min_size_box):
if np.any(contour[:, 0].max(axis=0) - contour[:, 0].min(axis=0) < 2):
charlesmindee marked this conversation as resolved.
Show resolved Hide resolved
continue
# Compute objectness
if self.assume_straight_pages:
Expand Down