Viz
Classes
Functions
valor.viz.create_combined_segmentation_mask(annotated_datum, label_key, filter_on_instance_segmentations=False)
Creates a combined segmentation mask from a list of segmentations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotated_datum
|
Union[GroundTruth, Prediction]
|
A list of segmentations. These all must have the same |
required |
label_key
|
str
|
The label key to use. |
required |
filter_on_instance_segmentations
|
bool
|
Whether to filter on instance segmentations or not. |
False
|
Returns:
Type | Description |
---|---|
tuple
|
The first element of the tuple is the combined mask, as an RGB PIL image. The second element is a color legend: it's a dict with the unique labels as keys and the PIL image swatches as values. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If all segmentations don't belong to the same image or there is a
segmentation that doesn't have |
ValueError
|
If there aren't any segmentations. |
Source code in valor/viz.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
valor.viz.draw_bounding_box_on_image(bounding_box, img, color=(255, 0, 0))
Draws a bounding polygon on an image. This operation is not done in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bounding_box
|
Box
|
Bounding box to draw on the image. |
required |
img
|
Image
|
Pillow image to draw on. |
required |
color
|
Tuple[int, int, int]
|
RGB tuple of the color to use. |
(255, 0, 0)
|
Returns:
Type | Description |
---|---|
img
|
Pillow image with bounding box drawn on it. |
Source code in valor/viz.py
valor.viz.draw_detections_on_image(detections, img)
Draws detections (bounding boxes and labels) on an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detections
|
List[Union[GroundTruth, Prediction]]
|
A list of |
required |
img
|
Image
|
The image to draw the detections on. |
required |
Returns:
Name | Type | Description |
---|---|---|
img |
Image
|
An image with the detections drawn on. |
Source code in valor/viz.py
valor.viz.draw_raster_on_image(raster, img, color=(255, 0, 0), alpha=0.4)
Draws the raster on top of an image. This operation is not done in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
Image
|
pillow image to draw on. |
required |
color
|
Tuple[int, int, int]
|
RGB tuple of the color to use |
(255, 0, 0)
|
alpha
|
float
|
alpha (transparency) value of the mask. 0 is fully transparent, 1 is fully opaque |
0.4
|