def run(generator, args):
    for i in range(generator.size()):
        image = generator.load_image(i)
        (annotations, masks) = generator.load_annotations(i)
        if args.random_transform:
            (image, annotations, masks) = generator.random_transform_group_entry(image, annotations, masks)
        if args.resize:
            (image, image_scale) = generator.resize_image(image)
            annotations[:, :4] *= image_scale
            for m in range(len(masks)):
                (masks[m], _) = generator.resize_image(masks[m])
        if args.anchors:
            (labels, _, anchors) = generator.compute_anchor_targets(image.shape, annotations, generator.num_classes())
            draw_boxes(image, anchors[(np.max(labels, axis=1) == 1)], (255, 255, 0), thickness=1)
        if args.annotations:
            draw_annotations(image, annotations, color=(0, 0, 255), label_to_name=generator.label_to_name)
            (labels, boxes, _) = generator.compute_anchor_targets(image.shape, annotations, generator.num_classes())
            draw_boxes(image, boxes[(np.max(labels, axis=1) == 1)], (0, 255, 0))
        if args.masks:
            for m in range(len(masks)):
                box = annotations[m, :4].astype(int)
                mask = masks[m][box[1]:box[3], box[0]:box[2]]
                draw_mask(image, box, mask, label_color(annotations[(m, 4)].astype(int)))
                caption = '{}'.format(generator.label_to_name(annotations[(m, 4)]))
                draw_caption(image, box, caption)
        cv2.imshow('Image', image)
        if (cv2.waitKey() == ord('q')):
            return False
    return True
def run(generator, args):
    for i in range(generator.size()):
        image = generator.load_image(i)
        (annotations, masks) = generator.load_annotations(i)
        if args.random_transform:
            (image, annotations, masks) = generator.random_transform_group_entry(image, annotations, masks)
        if args.resize:
            (image, image_scale) = generator.resize_image(image)
            annotations[:, :4] *= image_scale
            for m in range(len(masks)):
                (masks[m], _) = generator.resize_image(masks[m])
        if args.anchors:
            (labels, _, anchors) = generator.compute_anchor_targets(image.shape, annotations, generator.num_classes())
            draw_boxes(image, anchors[(np.max(labels, axis=1) == 1)], (255, 255, 0), thickness=1)
        if args.annotations:
            draw_annotations(image, annotations, color=(0, 0, 255), label_to_name=generator.label_to_name)
            (labels, boxes, _) = generator.compute_anchor_targets(image.shape, annotations, generator.num_classes())
            draw_boxes(image, boxes[(np.max(labels, axis=1) == 1)], (0, 255, 0))
        if args.masks:
            for m in range(len(masks)):
                box = annotations[m, :4].astype(int)
                mask = masks[m][box[1]:box[3], box[0]:box[2]]
                draw_mask(image, box, mask, label_color(annotations[(m, 4)].astype(int)))
                caption = '{}'.format(generator.label_to_name(annotations[(m, 4)]))
                draw_caption(image, box, caption)
        cv2.imshow('Image', image)
        if (cv2.waitKey() == ord('q')):
            return False
    return True