Implement YOLOx for RKNN (#17788)

* Implement yolox rknn inference and post processing

* rework docs
This commit is contained in:
Nicolas Mowen
2025-04-18 14:44:02 -06:00
committed by GitHub
parent 68382d89b4
commit 1cdc9b6097
4 changed files with 169 additions and 65 deletions

View File

@@ -24,7 +24,7 @@ class DetectionApi(ABC):
def detect_raw(self, tensor_input):
pass
def calculate_grids_strides(self) -> None:
def calculate_grids_strides(self, expanded=True) -> None:
grids = []
expanded_strides = []
@@ -35,10 +35,23 @@ class DetectionApi(ABC):
for hsize, wsize, stride in zip(hsizes, wsizes, strides):
xv, yv = np.meshgrid(np.arange(wsize), np.arange(hsize))
grid = np.stack((xv, yv), 2).reshape(1, -1, 2)
grids.append(grid)
shape = grid.shape[:2]
expanded_strides.append(np.full((*shape, 1), stride))
self.grids = np.concatenate(grids, 1)
self.expanded_strides = np.concatenate(expanded_strides, 1)
if expanded:
grid = np.stack((xv, yv), 2).reshape(1, -1, 2)
grids.append(grid)
shape = grid.shape[:2]
expanded_strides.append(np.full((*shape, 1), stride))
else:
xv = xv.reshape(1, 1, hsize, wsize)
yv = yv.reshape(1, 1, hsize, wsize)
grids.extend(np.concatenate((xv, yv), axis=1).tolist())
expanded_strides.extend(
np.array([stride, stride]).reshape(1, 2, 1, 1).tolist()
)
if expanded:
self.grids = np.concatenate(grids, 1)
self.expanded_strides = np.concatenate(expanded_strides, 1)
else:
self.grids = grids
self.expanded_strides = expanded_strides