def visualize_detections_for_sequence(tag, det_boxes, det_scores, det_classes, det_masks, imgs, add_masks, interactive_visualization, model_str): if len(imgs) > len(det_boxes): print("warning, len of imgs and det_boxes does not match", len(imgs), len(det_boxes), file=log.v1) imgs = imgs[:len(det_boxes)] assert len(det_boxes) == len(imgs) for t, (boxes, scores, classes, masks, img) in enumerate(zip(det_boxes, det_scores, det_classes, det_masks, imgs)): if add_masks: masks_decoded = [cocomask.decode(m) for m in masks] else: masks_decoded = [None for _ in boxes] if interactive_visualization: out_filename = None else: out_folder = "forwarded/" + model_str + "/vis/detections/" + tag os.makedirs(out_folder, exist_ok=True) out_filename = out_folder + "/%06d.jpg" % t visualize_detections(boxes, classes, masks_decoded, scores, img, None, out_filename)
def visualize_tracks(tag, tracks, imgs, add_masks, interactive_visualization, model_str, box_is_xywh=False): if len(imgs) > len(tracks): print("warning, len of imgs and tracks does not match", len(imgs), len(tracks), file=log.v1) imgs = imgs[:len(tracks)] assert len(tracks) == len(imgs), (len(tracks), len(imgs)) for t, (track, img) in enumerate(zip(tracks, imgs)): boxes = [te.box for te in track] classes = [te.class_ for te in track] if add_masks: masks = [cocomask.decode(te.mask) for te in track] else: masks = [None for _ in track] scores = [1.0 for _ in track] ids = [te.track_id for te in track] if interactive_visualization: out_filename = None else: out_folder = "forwarded/" + model_str + "/vis/tracks/" + tag os.makedirs(out_folder, exist_ok=True) out_filename = out_folder + "/%06d.jpg" % t visualize_detections(boxes, classes, masks, scores, img, ids, out_filename, box_is_xywh=box_is_xywh)