10
10
import hypothesis .strategies as st
11
11
import numpy as np
12
12
13
+
13
14
def generate_rois (roi_counts , im_dims ):
14
15
assert len (roi_counts ) == len (im_dims )
15
16
all_rois = []
@@ -36,6 +37,7 @@ def generate_rois(roi_counts, im_dims):
36
37
return np .vstack (all_rois )
37
38
return np .empty ((0 , 5 )).astype (np .float32 )
38
39
40
+
39
41
def generate_rois_rotated (roi_counts , im_dims ):
40
42
rois = generate_rois (roi_counts , im_dims )
41
43
# [batch_id, ctr_x, ctr_y, w, h, angle]
@@ -48,6 +50,7 @@ def generate_rois_rotated(roi_counts, im_dims):
48
50
rotated_rois [:, 5 ] = np .random .uniform (- 90.0 , 90.0 ) # angle in degrees
49
51
return rotated_rois
50
52
53
+
51
54
class TorchIntegration (hu .HypothesisTestCase ):
52
55
53
56
@given (
@@ -58,15 +61,16 @@ class TorchIntegration(hu.HypothesisTestCase):
58
61
clip_angle_thresh = st .sampled_from ([- 1.0 , 1.0 ]),
59
62
** hu .gcs_cpu_only
60
63
)
61
- def test_bbox_transform (self ,
64
+ def test_bbox_transform (
65
+ self ,
62
66
roi_counts ,
63
67
num_classes ,
64
68
rotated ,
65
69
angle_bound_on ,
66
70
clip_angle_thresh ,
67
71
gc ,
68
72
dc ,
69
- ):
73
+ ):
70
74
"""
71
75
Test with rois for multiple images in a batch
72
76
"""
@@ -91,7 +95,6 @@ def bbox_transform_ref():
91
95
["rois" , "deltas" , "im_info" ],
92
96
["box_out" ],
93
97
apply_scale = False ,
94
- correct_transform_coords = True ,
95
98
rotated = rotated ,
96
99
angle_bound_on = angle_bound_on ,
97
100
clip_angle_thresh = clip_angle_thresh ,
@@ -107,7 +110,7 @@ def bbox_transform_ref():
107
110
torch .tensor (rois ), torch .tensor (deltas ),
108
111
torch .tensor (im_info ),
109
112
[1.0 , 1.0 , 1.0 , 1.0 ],
110
- False , True , rotated , angle_bound_on ,
113
+ False , rotated , angle_bound_on ,
111
114
- 90 , 90 , clip_angle_thresh )
112
115
113
116
torch .testing .assert_allclose (box_out , a )
@@ -117,7 +120,7 @@ def bbox_transform_ref():
117
120
H = st .integers (min_value = 10 , max_value = 10 ),
118
121
W = st .integers (min_value = 8 , max_value = 8 ),
119
122
img_count = st .integers (min_value = 3 , max_value = 3 ),
120
- )
123
+ )
121
124
def test_generate_proposals (self , A , H , W , img_count ):
122
125
scores = np .ones ((img_count , A , H , W )).astype (np .float32 )
123
126
bbox_deltas = np .linspace (0 , 10 , num = img_count * 4 * A * H * W ).reshape (
@@ -145,6 +148,6 @@ def generate_proposals_ref():
145
148
a , b = torch .ops ._caffe2 .GenerateProposals (
146
149
torch .tensor (scores ), torch .tensor (bbox_deltas ),
147
150
torch .tensor (im_info ), torch .tensor (anchors ),
148
- 2.0 , 6000 , 300 , 0.7 , 16 , False , True , - 90 , 90 , 1.0 )
151
+ 2.0 , 6000 , 300 , 0.7 , 16 , True , - 90 , 90 , 1.0 )
149
152
torch .testing .assert_allclose (rois , a )
150
153
torch .testing .assert_allclose (rois_probs , b )
0 commit comments