Fixed creation of structured array
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -429,7 +429,7 @@ def _apply_entropy_threshold(observations: Sequence[np.ndarray], entropy_thresho
|
|||||||
def _apply_top_k(detections: Sequence[np.ndarray], top_k: float) -> List[np.ndarray]:
|
def _apply_top_k(detections: Sequence[np.ndarray], top_k: float) -> List[np.ndarray]:
|
||||||
final_detections = []
|
final_detections = []
|
||||||
batch_size = len(detections)
|
batch_size = len(detections)
|
||||||
data_type = np.dtype([('image_id', np.int32),
|
data_type = np.dtype([('class_id', np.int32),
|
||||||
('confidence', 'f4'),
|
('confidence', 'f4'),
|
||||||
('entropy', 'f4'),
|
('entropy', 'f4'),
|
||||||
('xmin', 'f4'),
|
('xmin', 'f4'),
|
||||||
@ -438,7 +438,8 @@ def _apply_top_k(detections: Sequence[np.ndarray], top_k: float) -> List[np.ndar
|
|||||||
('ymax', 'f4')])
|
('ymax', 'f4')])
|
||||||
for i in range(batch_size):
|
for i in range(batch_size):
|
||||||
image_detections = detections[i]
|
image_detections = detections[i]
|
||||||
image_detections_structured = np.array(image_detections, dtype=data_type)
|
image_detections_structured = np.core.records.fromarrays(image_detections.transpose(),
|
||||||
|
dtype=data_type)
|
||||||
descending_indices = np.argsort(-image_detections_structured['confidence'])
|
descending_indices = np.argsort(-image_detections_structured['confidence'])
|
||||||
image_detections_sorted = np.asarray(image_detections_structured[descending_indices])
|
image_detections_sorted = np.asarray(image_detections_structured[descending_indices])
|
||||||
top_k_indices = np.argpartition(image_detections_sorted[:, 1],
|
top_k_indices = np.argpartition(image_detections_sorted[:, 1],
|
||||||
|
|||||||
Reference in New Issue
Block a user