MCPcopy Create free account
hub / github.com/Atrovast/THGS / masks_update

Function masks_update

scripts/image_encoding.py:284–297  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

282 return selected_idx
283
284def masks_update(*args, **kwargs):
285 # remove redundant masks based on the scores and overlap rate between masks
286 masks_new = ()
287 for masks_lvl in (args):
288 seg_pred = torch.from_numpy(np.stack([m['segmentation'] for m in masks_lvl], axis=0)).cuda()
289 iou_pred = torch.from_numpy(np.stack([m['predicted_iou'] for m in masks_lvl], axis=0)).cuda()
290 stability = torch.from_numpy(np.stack([m['stability_score'] for m in masks_lvl], axis=0)).cuda()
291
292 scores = stability * iou_pred
293 keep_mask_nms = mask_nms(seg_pred, scores, **kwargs)
294 masks_lvl = filter(keep_mask_nms, masks_lvl)
295
296 masks_new += (masks_lvl,)
297 return masks_new
298
299def sam_encoder(image):
300 image = cv2.cvtColor(image[0].permute(1,2,0).numpy().astype(np.uint8), cv2.COLOR_BGR2RGB)

Callers 1

sam_encoderFunction · 0.85

Calls 3

mask_nmsFunction · 0.85
filterFunction · 0.85
cudaMethod · 0.45

Tested by

no test coverage detected