Open changtimwu opened 3 years ago
def _get_embeddings(self, frame, detections, mask=None):
rois = []
embeddings = []
if self.analyzer:
self.current_detections = []
for i in range(len(detections)):
rect = detections[i]
left, top, right, bottom = rect
crop = frame[top:bottom, left:right]
if mask and len(mask[i]) > 0:
crop = cv2.bitwise_and(crop, crop, mask=mask[i])
if left != right and top != bottom:
rois.append(crop)
if self.analyzer:
self.current_detections.append(cv2.resize(crop, self.analyzer.crop_size))
if rois:
embeddings = self.reid_model.forward(rois)
assert len(rois) == len(embeddings)
return embeddings
key point
quote from an official reid model info