ReFeed
- class lib.infer.align.ReFeed(re_feeds: int)
Bases:
objectHandles preparation of images for re-feeding the aligner with minor adjustments to detection bounding boxes, and averaging the result at the end.
- Parameters:
re_feeds (int) – The number of re-feeds to be performed.
Methods Summary
__call__(-> npt.NDArray[np.float32])Obtain an array of adjusted norm to frame matrices based on the number of re-feed iterations that have been selected and the size of the original ROI.
merge(landmarks)If re-feeds enabled return the average result from the re-feeds, otherwise the original array
Methods Documentation
- __call__(matrices: npt.NDArray[np.float32], with_roi: Literal[False], size: int = 0) npt.NDArray[np.float32]
- __call__(matrices: npt.NDArray[np.float32], with_roi: Literal[True] = True, size: int = 0) tuple[npt.NDArray[np.float32], npt.NDArray[np.int32]]
Obtain an array of adjusted norm to frame matrices based on the number of re-feed iterations that have been selected and the size of the original ROI.
- Parameters:
matrices (npt.NDArray[np.float32]) – A batch of norm to frame transformation matrices to be randomly adjust for re-feeding the model in shape (N, 3, 3)
with_roi (bool) –
Trueto also return the adjusted ROIs. Default:Falsesize (int) – The size of the image patch that the matrix creates if it cannot be derived from the matrices. Default: 0 (derive from matrices)
- Returns:
matrices – The adjusted matrices for taking points from normalized to frame space in shape ((Num re_feeds * N) + 1, 3, 3), in frame contiguous order (Na, Nb, Nc, Na1, Nb1, Nc1…)
roi – The ((Num re_feeds * N) + 1, 4) roi for each adjusted feed. Returned if with_roi is
True
- Return type:
npt.NDArray[np.float32] | tuple[npt.NDArray[np.float32], npt.NDArray[np.int32]]
- merge(landmarks: npt.NDArray[np.float32]) npt.NDArray[np.float32]
If re-feeds enabled return the average result from the re-feeds, otherwise the original array
- Parameters:
landmarks (npt.NDArray[np.float32]) – The (N x total_feeds, 68, 2) landmarks from the plugin
- Return type:
The final (N, 68, 2) landmarks with any re-feeds merged
- __call__(matrices: npt.NDArray[np.float32], with_roi: Literal[False], size: int = 0) npt.NDArray[np.float32]
- __call__(matrices: npt.NDArray[np.float32], with_roi: Literal[True] = True, size: int = 0) tuple[npt.NDArray[np.float32], npt.NDArray[np.int32]]
Obtain an array of adjusted norm to frame matrices based on the number of re-feed iterations that have been selected and the size of the original ROI.
- Parameters:
matrices (npt.NDArray[np.float32]) – A batch of norm to frame transformation matrices to be randomly adjust for re-feeding the model in shape (N, 3, 3)
with_roi (bool) –
Trueto also return the adjusted ROIs. Default:Falsesize (int) – The size of the image patch that the matrix creates if it cannot be derived from the matrices. Default: 0 (derive from matrices)
- Returns:
matrices – The adjusted matrices for taking points from normalized to frame space in shape ((Num re_feeds * N) + 1, 3, 3), in frame contiguous order (Na, Nb, Nc, Na1, Nb1, Nc1…)
roi – The ((Num re_feeds * N) + 1, 4) roi for each adjusted feed. Returned if with_roi is
True
- Return type:
npt.NDArray[np.float32] | tuple[npt.NDArray[np.float32], npt.NDArray[np.int32]]
- beta
The amount each corner point can move relative to the boxes shortest side
- merge(landmarks: npt.NDArray[np.float32]) npt.NDArray[np.float32]
If re-feeds enabled return the average result from the re-feeds, otherwise the original array
- Parameters:
landmarks (npt.NDArray[np.float32]) – The (N x total_feeds, 68, 2) landmarks from the plugin
- Return type:
The final (N, 68, 2) landmarks with any re-feeds merged
- total_feeds
The total number of feeds through the model for original boxes plus re-feeds