MCPcopy Create free account
hub / github.com/HYUNJS/SGT / transform_boxes

Method transform_boxes

projects/SGT/sgt/meta_arch/sgt.py:135–159  ·  view source on GitHub ↗

transform predicted boxes to target boxes Args: boxes: Tensor torch Tensor with (Batch, N, 4) shape img_info: Dict dict contains all information of original image scale: float used for multiscale te

(boxes, img_info, scale=1)

Source from the content-addressed store, hash-verified

133
134 @staticmethod
135 def transform_boxes(boxes, img_info, scale=1):
136 '''
137 transform predicted boxes to target boxes
138
139 Args:
140 boxes: Tensor
141 torch Tensor with (Batch, N, 4) shape
142 img_info: Dict
143 dict contains all information of original image
144 scale: float
145 used for multiscale testing
146 '''
147 boxes = boxes.cpu().numpy().reshape(-1, 4)
148
149 center = img_info['center']
150 size = img_info['size']
151 output_size = (img_info['width'], img_info['height'])
152 src, dst = CenterAffine.generate_src_and_dst(center, size, output_size)
153 trans = cv2.getAffineTransform(np.float32(dst), np.float32(src))
154
155 coords = boxes.reshape(-1, 2)
156 aug_coords = np.column_stack((coords, np.ones(coords.shape[0])))
157 target_boxes = np.dot(aug_coords, trans.T).reshape(-1, 4)
158
159 return target_boxes

Callers 1

_postprocessMethod · 0.95

Calls 1

generate_src_and_dstMethod · 0.45

Tested by

no test coverage detected