def draw_gt_instances_d2(gt_instances, img, metadata, scale, instance_mode):
    """Wrapper of D2's 'Visualizer.draw_instance_predictions()' to render GT instances.
    """
    # Rename instance fields to work with Visualizer.draw_instance_predictions() of detectron2.
    field_remapping = {
        'gt_boxes': 'pred_boxes',
        'gt_classes': 'pred_classes',
    }
    fields = {}
    for k, v in gt_instances._fields.items():
        new_k = field_remapping.get(k, None)
        k = new_k or k
        fields[k] = v

    instances = Instances(image_size=gt_instances._image_size, **fields)
    viz = Visualizer(img, metadata, scale=scale, instance_mode=instance_mode)
    viz_image = viz.draw_instance_predictions(instances).get_image()
    return viz_image
Wrapper of D2's 'Visualizer.draw_instance_predictions()' to render GT instances.
    
tridet/visualizers/d2_visualizer.py