Skip to content

Commit c08ddc5

Browse files
rebase & update
1 parent a5b94c7 commit c08ddc5

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

docs/source/modules/models.rst

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ doctr.models.classification
2727

2828
.. autofunction:: doctr.models.classification.mobilenet_v3_small_crop_orientation
2929

30+
.. autofunction:: doctr.models.classification.mobilenet_v3_small_page_orientation
31+
3032
.. autofunction:: doctr.models.classification.magc_resnet31
3133

3234
.. autofunction:: doctr.models.classification.vit_s
@@ -41,6 +43,8 @@ doctr.models.classification
4143

4244
.. autofunction:: doctr.models.classification.crop_orientation_predictor
4345

46+
.. autofunction:: doctr.models.classification.page_orientation_predictor
47+
4448

4549
doctr.models.detection
4650
----------------------

tests/pytorch/test_models_classification_pt.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,16 @@ def test_crop_orientation_model(mock_text_box):
136136

137137

138138
def test_page_orientation_model(mock_payslip):
139-
image_rot_0 = cv2.imread(mock_payslip)
139+
text_box_0 = cv2.imread(mock_payslip)
140140
# rotates counter-clockwise
141-
image_rot_90 = np.rot90(image_rot_0, 3)
142-
image_rot_180 = np.rot90(image_rot_0, 2)
143-
image_rot_270 = np.rot90(image_rot_0, 1)
144-
classifier = classification.page_orientation_predictor("mobilenet_v3_small_page_orientation", pretrained=True)
145-
assert classifier([image_rot_0, image_rot_270, image_rot_180, image_rot_90])[0] == [0, 1, 2, 3]
141+
text_box_270 = np.rot90(text_box_0, 1)
142+
text_box_180 = np.rot90(text_box_0, 2)
143+
text_box_90 = np.rot90(text_box_0, 3)
144+
classifier = classification.crop_orientation_predictor("mobilenet_v3_small_page_orientation", pretrained=True)
145+
assert classifier([text_box_0, text_box_270, text_box_180, text_box_90])[0] == [0, 1, 2, 3]
146146
# 270 degrees is equivalent to -90 degrees
147-
assert classifier([image_rot_0, image_rot_270, image_rot_180, image_rot_90])[1] == [0, -90, 180, 90]
148-
assert all(
149-
isinstance(pred, float) for pred in classifier([image_rot_0, image_rot_270, image_rot_180, image_rot_90])[2]
150-
)
147+
assert classifier([text_box_0, text_box_270, text_box_180, text_box_90])[1] == [0, -90, 180, 90]
148+
assert all(isinstance(pred, float) for pred in classifier([text_box_0, text_box_270, text_box_180, text_box_90])[2])
151149

152150

153151
@pytest.mark.parametrize(

tests/tensorflow/test_models_classification_tf.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,16 @@ def test_crop_orientation_model(mock_text_box):
116116

117117

118118
def test_page_orientation_model(mock_payslip):
119-
image_rot_0 = cv2.imread(mock_payslip)
119+
text_box_0 = cv2.imread(mock_payslip)
120120
# rotates counter-clockwise
121-
image_rot_90 = np.rot90(image_rot_0, 3)
122-
image_rot_180 = np.rot90(image_rot_0, 2)
123-
image_rot_270 = np.rot90(image_rot_0, 1)
124-
classifier = classification.page_orientation_predictor("mobilenet_v3_small_page_orientation", pretrained=True)
125-
assert classifier([image_rot_0, image_rot_270, image_rot_180, image_rot_90])[0] == [0, 1, 2, 3]
121+
text_box_270 = np.rot90(text_box_0, 1)
122+
text_box_180 = np.rot90(text_box_0, 2)
123+
text_box_90 = np.rot90(text_box_0, 3)
124+
classifier = classification.crop_orientation_predictor("mobilenet_v3_small_page_orientation", pretrained=True)
125+
assert classifier([text_box_0, text_box_270, text_box_180, text_box_90])[0] == [0, 1, 2, 3]
126126
# 270 degrees is equivalent to -90 degrees
127-
assert classifier([image_rot_0, image_rot_270, image_rot_180, image_rot_90])[1] == [0, -90, 180, 90]
128-
assert all(
129-
isinstance(pred, float) for pred in classifier([image_rot_0, image_rot_270, image_rot_180, image_rot_90])[2]
130-
)
127+
assert classifier([text_box_0, text_box_270, text_box_180, text_box_90])[1] == [0, -90, 180, 90]
128+
assert all(isinstance(pred, float) for pred in classifier([text_box_0, text_box_270, text_box_180, text_box_90])[2])
131129

132130

133131
# temporarily fix to avoid killing the CI (tf2onnx v1.14 memory leak issue)

0 commit comments

Comments
 (0)