Skip to content

Commit

Permalink
fix: requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesmindee committed Dec 29, 2021
1 parent 3d96945 commit 2d16432
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doctr/models/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def rectify_loc_preds(
return np.stack(
[np.roll(
page_loc_pred,
orientation - 1,
orientation,
axis=0) for orientation, page_loc_pred in zip(orientations, page_loc_preds)],
axis=0
) if len(orientations) > 0 else None
6 changes: 3 additions & 3 deletions doctr/models/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def _sort_boxes(boxes: np.ndarray) -> np.ndarray:
Returns:
tuple: indices of ordered boxes of shape (N,), boxes
If straight boxes are passed tpo the function, boxes are unchanged
else: boxes returned are straight boxes fitted to the straightened rotated boxes
so that we fit the lines afterwards to the straigthened page
If straight boxes are passed tpo the function, boxes are unchanged
else: boxes returned are straight boxes fitted to the straightened rotated boxes
so that we fit the lines afterwards to the straigthened page
"""
if boxes.ndim == 3:
boxes = rotate_boxes(
Expand Down
4 changes: 2 additions & 2 deletions doctr/models/detection/differentiable_binarization/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def polygon_to_box(
expanded_points = np.asarray(_points) # expand polygon
if len(expanded_points) < 1:
return None
return cv2.boundingRect(expanded_points) if self.assume_straight_pages else cv2.boxPoints(
cv2.minAreaRect(expanded_points)
return cv2.boundingRect(expanded_points) if self.assume_straight_pages else np.roll(
cv2.boxPoints(cv2.minAreaRect(expanded_points)), -1, axis=0
)

def bitmap_to_boxes(
Expand Down
12 changes: 8 additions & 4 deletions doctr/models/detection/differentiable_binarization/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
'url': 'https://github.com/mindee/doctr/releases/download/v0.3.1/db_mobilenet_v3_large-fd62154b.pt',
},
'db_resnet50_rotation': {
'backbone': resnet50,
'backbone_submodule': None,
'fpn_layers': ['layer1', 'layer2', 'layer3', 'layer4'],
'input_shape': (3, 1024, 1024),
'mean': (0.798, 0.785, 0.772),
'std': (0.264, 0.2749, 0.287),
Expand Down Expand Up @@ -393,4 +390,11 @@ def db_resnet50_rotation(pretrained: bool = False, **kwargs: Any) -> DBNet:
text detection architecture
"""

return _dbnet('db_resnet50_rotation', pretrained, **kwargs)
return _dbnet(
'db_resnet50_rotation',
pretrained,
resnet50,
['layer1', 'layer2', 'layer3', 'layer4'],
None,
**kwargs,
)
1 change: 1 addition & 0 deletions doctr/models/detection/zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

if is_tf_available():
ARCHS = ['db_resnet50', 'db_mobilenet_v3_large', 'linknet_resnet18']
ROT_ARCHS = []
elif is_torch_available():
ARCHS = ['db_resnet34', 'db_resnet50', 'db_mobilenet_v3_large', 'linknet_resnet18', 'db_resnet50_rotation']
ROT_ARCHS = ['db_resnet50_rotation']
Expand Down
1 change: 0 additions & 1 deletion doctr/transforms/modules/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def extra_repr(self) -> str:

def __call__(self, img: tf.Tensor) -> tf.Tensor:
input_dtype = img.dtype
print(self.output_size)
img = tf.image.resize(img, self.output_size, self.method, self.preserve_aspect_ratio)
if self.preserve_aspect_ratio:
# pad width
Expand Down

0 comments on commit 2d16432

Please sign in to comment.