ocl.visualizations
VisualizationMethod
Bases: ABC
Abstract base class of a visualization method.
Source code in ocl/visualizations.py
__call__
abstractmethod
Comput visualization output.
A visualization method takes some inputs and returns a Visualization.
Image
Bases: VisualizationMethod
Visualize an image.
Source code in ocl/visualizations.py
__init__
Initialize image visualization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_instances |
int
|
Number of instances to visualize |
8
|
n_row |
int
|
Number of rows when |
8
|
denormalization |
Optional[Callable[[torch.Tensor], torch.Tensor]]
|
Function to map from normalized inputs to unnormalized values |
None
|
as_grid |
bool
|
Output a grid of images |
True
|
Source code in ocl/visualizations.py
__call__
Visualize image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
torch.Tensor
|
Tensor to visualize as image |
required |
Returns:
Type | Description |
---|---|
Union[visualization_types.Image, visualization_types.Images]
|
Visualized image or images. |
Source code in ocl/visualizations.py
Video
Bases: VisualizationMethod
Source code in ocl/visualizations.py
__init__
Initialize video visualization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_instances |
int
|
Number of instances to visualize |
8
|
n_row |
int
|
Number of rows when |
8
|
denormalization |
Optional[Callable[[torch.Tensor], torch.Tensor]]
|
Function to map from normalized inputs to unnormalized values |
None
|
as_grid |
bool
|
Output a grid of images |
True
|
fps |
int
|
Frames per second |
10
|
Source code in ocl/visualizations.py
__call__
Visualize video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video |
torch.Tensor
|
Tensor to visualize as video |
required |
Returns:
Type | Description |
---|---|
visualization_types.Video
|
Visualized video. |
Source code in ocl/visualizations.py
Mask
Bases: VisualizationMethod
Source code in ocl/visualizations.py
__init__
__call__
Visualize mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask |
torch.Tensor
|
Tensor to visualize as mask |
required |
Returns:
Type | Description |
---|---|
Union[visualization_types.Image, visualization_types.Video]
|
Visualized mask. |
Source code in ocl/visualizations.py
VisualObject
Bases: VisualizationMethod
Source code in ocl/visualizations.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
__init__
Initialize VisualObject visualization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_instances |
int
|
Number of masks to visualize |
8
|
denormalization |
Optional[Callable[[torch.Tensor], torch.Tensor]]
|
Function to map from normalized inputs to unnormalized values |
None
|
fps |
int
|
Frames per second in the case of video input. |
10
|
Source code in ocl/visualizations.py
__call__
Visualize a visual object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
object |
torch.Tensor
|
Tensor of objects to visualize |
required |
mask |
torch.Tensor
|
Tensor of object masks |
required |
Returns:
Type | Description |
---|---|
Union[Dict[str, visualization_types.Image], Dict[str, visualization_types.Video]]
|
Visualized objects as masked images and masks in the keys |
Source code in ocl/visualizations.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
Segmentation
Bases: VisualizationMethod
Segmentaiton visualization.
Source code in ocl/visualizations.py
__init__
Initialize segmentation visualization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_instances |
int
|
Number of masks to visualize |
8
|
denormalization |
Optional[Callable[[torch.Tensor], torch.Tensor]]
|
Function to map from normalized inputs to unnormalized values |
None
|
Source code in ocl/visualizations.py
__call__
Visualize segmentation overlaying original image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
torch.Tensor
|
Image to overlay |
required |
mask |
torch.Tensor
|
Masks of individual objects |
required |
Source code in ocl/visualizations.py
masks_to_bboxes_xyxy
Compute bounding boxes around the provided masks.
Adapted from DETR: https://github.com/facebookresearch/detr/blob/main/util/box_ops.py
Parameters:
Name | Type | Description | Default |
---|---|---|---|
masks |
torch.Tensor
|
Tensor of shape (N, H, W), where N is the number of masks, H and W are the spatial dimensions. |
required |
empty_value |
float
|
Value bounding boxes should contain for empty masks. |
-1.0
|
Returns:
Type | Description |
---|---|
torch.Tensor
|
Tensor of shape (N, 4), containing bounding boxes in (x1, y1, x2, y2) format, where (x1, y1) |
torch.Tensor
|
is the coordinate of top-left corner and (x2, y2) is the coordinate of the bottom-right |
torch.Tensor
|
corner (inclusive) in pixel coordinates. If mask is empty, all coordinates contain |
torch.Tensor
|
|