MCPcopy
hub / github.com/sml2h3/ddddocr / demo_postprocess

Method demo_postprocess

ddddocr/core/detection_engine.py:106–126  ·  view source on GitHub ↗

后处理函数(来自原始代码)

(self, outputs, img_size, p6=False)

Source from the content-addressed store, hash-verified

104 return padded_img, r
105
106 def demo_postprocess(self, outputs, img_size, p6=False):
107 """后处理函数(来自原始代码)"""
108 grids = []
109 expanded_strides = []
110 if not p6:
111 strides = [8, 16, 32]
112 else:
113 strides = [8, 16, 32, 64]
114 hsizes = [img_size[0] // stride for stride in strides]
115 wsizes = [img_size[1] // stride for stride in strides]
116 for hsize, wsize, stride in zip(hsizes, wsizes, strides):
117 xv, yv = np.meshgrid(np.arange(wsize), np.arange(hsize))
118 grid = np.stack((xv, yv), 2).reshape(1, -1, 2)
119 grids.append(grid)
120 shape = grid.shape[:2]
121 expanded_strides.append(np.full((*shape, 1), stride))
122 grids = np.concatenate(grids, 1)
123 expanded_strides = np.concatenate(expanded_strides, 1)
124 outputs[..., :2] = (outputs[..., :2] + grids) * expanded_strides
125 outputs[..., 2:4] = np.exp(outputs[..., 2:4]) * expanded_strides
126 return outputs
127
128 def nms(self, boxes, scores, nms_thr):
129 """Single class NMS implemented in Numpy."""

Callers 1

get_bboxMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected