Status: Needs Review
This page has not been reviewed for accuracy and completeness. Content may be outdated or contain errors.
Visualization Nodes¶
Visualization nodes cover mask overlays, tracking overlays, false-RGB monitoring, and pipeline comparison artifacts.
Anomaly And Tracking Visualization¶
anomaly_visualization
¶
Anomaly detection visualization sink nodes for monitoring training progress.
ImageArtifactVizBase
¶
Bases: Node
Base class for visualization nodes that produce image artifacts.
Source code in cuvis_ai/node/anomaly_visualization.py
AnomalyMask
¶
Bases: Node
Visualize anomaly detection with GT and predicted masks.
Creates side-by-side visualizations showing ground truth masks, predicted masks, and overlay comparisons on hyperspectral cube images. The overlay shows:
- Green: True Positives (correct anomaly detection)
- Red: False Positives (false alarms)
- Yellow: False Negatives (missed anomalies)
Also displays IoU and other metrics. Returns a list of Artifact objects for logging to monitoring systems.
Executes during validation and inference stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
Channel index to use for cube visualization (required) |
required |
up_to
|
int
|
Maximum number of images to visualize. If None, visualizes all (default: None) |
None
|
Examples:
>>> decider = BinaryDecider(threshold=0.2)
>>> viz_mask = AnomalyMask(channel=30, up_to=5)
>>> tensorboard_node = TensorBoardMonitorNode(output_dir="./runs")
>>> graph.connect(
... (logit_head.logits, decider.data),
... (decider.decisions, viz_mask.decisions),
... (data_node.mask, viz_mask.mask),
... (data_node.cube, viz_mask.cube),
... (viz_mask.artifacts, tensorboard_node.artifacts),
... )
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Create anomaly mask visualizations with GT/pred comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decisions
|
Tensor
|
Binary anomaly decisions [B, H, W, 1] |
required |
mask
|
Tensor | None
|
Ground truth anomaly mask [B, H, W, 1] (optional) |
None
|
cube
|
Tensor
|
Original cube [B, H, W, C] for visualization |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with "artifacts" key containing list of Artifact objects |
Source code in cuvis_ai/node/anomaly_visualization.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
ScoreHeatmapVisualizer
¶
Bases: Node
Log LAD/RX score heatmaps as TensorBoard artifacts.
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Generate heatmap visualizations of anomaly scores.
Creates color-mapped heatmaps of anomaly scores for visualization in TensorBoard. Optionally normalizes scores to [0, 1] range for consistent visualization across batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
Tensor
|
Anomaly scores [B, H, W, 1] from detection nodes (e.g., RX, LAD). |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx information. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[Artifact]]
|
Dictionary with "artifacts" key containing list of heatmap artifacts. |
Source code in cuvis_ai/node/anomaly_visualization.py
RGBAnomalyMask
¶
Bases: Node
Visualize anomaly detection with GT and predicted masks on RGB images.
Similar to AnomalyMask but designed for RGB images (e.g., from band selectors). Creates side-by-side visualizations showing ground truth masks, predicted masks, and overlay comparisons on RGB images. The overlay shows:
- Green: True Positives (correct anomaly detection)
- Red: False Positives (false alarms)
- Yellow: False Negatives (missed anomalies)
Also displays IoU and other metrics. Returns a list of Artifact objects for logging to monitoring systems.
Executes during validation and inference stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
up_to
|
int
|
Maximum number of images to visualize. If None, visualizes all (default: None) |
None
|
Examples:
>>> decider = BinaryDecider(threshold=0.2)
>>> viz_mask = RGBAnomalyMask(up_to=5)
>>> tensorboard_node = TensorBoardMonitorNode(output_dir="./runs")
>>> graph.connect(
... (decider.decisions, viz_mask.decisions),
... (data_node.mask, viz_mask.mask),
... (band_selector.rgb_image, viz_mask.rgb_image),
... (viz_mask.artifacts, tensorboard_node.artifacts),
... )
Initialize RGBAnomalyMask visualizer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
up_to
|
int | None
|
Maximum number of images to visualize. If None, visualizes all (default: None) |
None
|
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Create anomaly mask visualizations with GT/pred comparison on RGB images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decisions
|
Tensor
|
Binary anomaly decisions [B, H, W, 1] |
required |
rgb_image
|
Tensor
|
RGB image [B, H, W, 3] for visualization |
required |
mask
|
Tensor | None
|
Ground truth anomaly mask [B, H, W, 1] (optional) |
None
|
context
|
Context | None
|
Execution context with stage, epoch, batch_idx |
None
|
scores
|
Tensor | None
|
Optional anomaly logits/scores [B, H, W, 1] |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with "artifacts" key containing list of Artifact objects |
Source code in cuvis_ai/node/anomaly_visualization.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | |
ChannelSelectorFalseRGBViz
¶
ChannelSelectorFalseRGBViz(
mask_overlay_alpha=0.4,
max_samples=4,
log_every_n_batches=1,
**kwargs,
)
Bases: ImageArtifactVizBase
Visualize false RGB output from channel selectors with optional mask overlay.
Produces per-sample image artifacts:
false_rgb_sample_{b}: Normalized false RGB image [H, W, 3]mask_overlay_sample_{b}: False RGB with red alpha-blend on foreground pixels (if mask provided)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask_overlay_alpha
|
float
|
Alpha value for red mask overlay on foreground pixels (default: 0.4). |
0.4
|
max_samples
|
int
|
Maximum number of batch elements to visualize (default: 4). |
4
|
log_every_n_batches
|
int
|
Log every N-th batch (default: 1). |
1
|
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Generate false RGB and mask overlay artifacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rgb_output
|
Tensor
|
False RGB tensor [B, H, W, 3]. |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx. |
required |
mask
|
Tensor | None
|
Optional segmentation mask [B, H, W]. |
None
|
mesu_index
|
Tensor | None
|
Optional measurement indices [B] for frame-identified artifact naming. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, list[Artifact]]
|
Dictionary with "artifacts" key containing image artifacts. |
Source code in cuvis_ai/node/anomaly_visualization.py
MaskOverlayNode
¶
Bases: Node
Alpha-blend a coloured mask overlay onto RGB frames.
Pure PyTorch processing node (no matplotlib, no gradients). When mask is
None or entirely zero the input RGB is passed through unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Blend factor for the overlay colour (default: 0.4). |
0.4
|
overlay_color
|
tuple[float, float, float]
|
RGB overlay colour in [0, 1] (default: red |
(1.0, 0.0, 0.0)
|
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Apply mask overlay to RGB frames.
Source code in cuvis_ai/node/anomaly_visualization.py
TrackingOverlayNode
¶
Bases: Node
Alpha-blend per-object coloured masks onto RGB frames.
Converts a SAM3-style label map (mask) into per-object binary masks and
renders a coloured overlay with optional contour lines and object-ID labels
using :func:cuvis_ai.utils.torch_draw.overlay_instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Blend factor for the overlay colour (default 0.4). |
0.4
|
draw_contours
|
bool
|
Draw contour outlines on mask edges (default True). |
True
|
draw_ids
|
bool
|
Render numeric object-ID labels above each mask (default True). |
True
|
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Render coloured per-object mask overlays onto rgb_image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rgb_image
|
Tensor
|
Single RGB frame |
required |
mask
|
Tensor
|
SAM3 label map |
required |
object_ids
|
Tensor or None
|
Active object IDs |
None
|
frame_id
|
Tensor or None
|
Frame / measurement index |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in cuvis_ai/node/anomaly_visualization.py
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | |
TrackingPointerOverlayNode
¶
Bases: Node
Draw downward triangle pointers for all tracked objects.
The node is composable by design: it renders only the pointer markers on top
of an incoming RGB frame and does not perform any mask tinting itself.
Colours are derived from object IDs using the same palette as
:class:TrackingOverlayNode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Reserved for API compatibility with :class: |
0.4
|
draw_contours
|
bool
|
Reserved for API compatibility with :class: |
True
|
draw_ids
|
bool
|
Reserved for API compatibility with :class: |
True
|
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Render pointer overlays for all objects onto rgb_image.
Source code in cuvis_ai/node/anomaly_visualization.py
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 | |
BBoxesOverlayNode
¶
BBoxesOverlayNode(
line_thickness=2,
draw_labels=False,
draw_sparklines=False,
sparkline_height=24,
hide_untracked=False,
**kwargs,
)
Bases: Node
Torch-only bounding-box overlay renderer for YOLO-style detections.
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
forward(
rgb_image,
bboxes,
category_ids,
frame_id=None,
confidences=None,
spectral_signatures=None,
**_,
)
Overlay bbox edges with deterministic per-class colors.
Source code in cuvis_ai/node/anomaly_visualization.py
ChannelWeightsViz
¶
Bases: ImageArtifactVizBase
Visualize channel mixer weights as a heatmap.
Produces a [K, C] mixing matrix heatmap with output channels on the
y-axis and input channels on the x-axis. Uses a diverging blue-white-red
colormap centred at zero so positive/negative contributions are immediately
visible.
Implemented in pure PyTorch (no matplotlib) so it adds negligible overhead to the training loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_samples
|
int
|
Ignored (weights are per-model, not per-sample). Kept for base class compatibility. Default: 1. |
1
|
log_every_n_batches
|
int
|
Log every N-th batch (default: 1). |
1
|
cell_height
|
int
|
Pixel height per matrix row (default: 40). |
60
|
cell_width
|
int
|
Pixel width per matrix column (default: 6). |
12
|
Source code in cuvis_ai/node/anomaly_visualization.py
forward
¶
Generate mixing matrix heatmap artifact.
Pure-torch rendering with R/G/B indicator bars, grid lines, and a diverging colorbar — no matplotlib for training-loop speed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights
|
Tensor
|
Mixing matrix |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx. |
required |
wavelengths
|
ndarray
|
Wavelengths |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, list[Artifact]]
|
Dictionary with |
Source code in cuvis_ai/node/anomaly_visualization.py
1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 | |
render_bboxes_overlay_torch
¶
render_bboxes_overlay_torch(
rgb_image,
bboxes,
category_ids,
frame_id=None,
line_thickness=2,
draw_labels=False,
spectral_signatures=None,
sparkline_height=24,
)
Render bbox edges on RGB frames using pure torch drawing primitives.
Source code in cuvis_ai/node/anomaly_visualization.py
Pipeline Visualization¶
pipeline_visualization
¶
Pipeline and data visualization sink nodes for monitoring training progress.
CubeRGBVisualizer
¶
Bases: Node
Creates false-color RGB images from hyperspectral cube using channel weights.
Selects 3 channels with highest weights for R, G, B channels and creates a false-color visualization with wavelength annotations.
Source code in cuvis_ai/node/pipeline_visualization.py
forward
¶
Generate false-color RGB visualizations from hyperspectral cube.
Selects the 3 channels with highest weights and creates RGB images with wavelength annotations. Also generates a bar chart showing channel weights with the selected channels highlighted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cube
|
Tensor
|
Hyperspectral cube [B, H, W, C]. |
required |
weights
|
Tensor
|
Channel selection weights [C] indicating importance of each channel. |
required |
wavelengths
|
Tensor
|
Wavelengths for each channel [C] in nanometers. |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx information. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[Artifact]]
|
Dictionary with "artifacts" key containing list of visualization artifacts. |
Source code in cuvis_ai/node/pipeline_visualization.py
PCAVisualization
¶
Bases: Node
Visualize PCA-projected data with scatter and image plots.
Creates visualizations for each batch element showing:
- Scatter plot of H*W points in 2D PC space (using first 2 PCs)
- Image representation of the 2D projection reshaped to [H, W, 2]
Points in scatter plot are colored by spatial position. Returns artifacts for monitoring systems.
Executes only during validation stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
up_to
|
int
|
Maximum number of batch elements to visualize. If None, visualizes all (default: None) |
None
|
Examples:
>>> pca_viz = PCAVisualization(up_to=10)
>>> tensorboard_node = TensorBoardMonitorNode(output_dir="./runs")
>>> graph.connect(
... (pca.projected, pca_viz.data),
... (pca_viz.artifacts, tensorboard_node.artifacts),
... )
Source code in cuvis_ai/node/pipeline_visualization.py
forward
¶
Create PCA projection visualizations as Artifact objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
PCA-projected data tensor [B, H, W, C] (uses first 2 components) |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with "artifacts" key containing list of Artifact objects |
Source code in cuvis_ai/node/pipeline_visualization.py
189 190 191 192 193 194 195 196 197 198 199 200 201 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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
PipelineComparisonVisualizer
¶
Bases: Node
TensorBoard visualization node for comparing pipeline stages.
Creates image artifacts for logging to TensorBoard:
- Input HSI cube visualization (false-color RGB from selected channels)
- Mixer output (3-channel RGB-like image that downstream model sees)
- Ground truth anomaly mask
- Anomaly scores (as heatmap)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hsi_channels
|
list[int]
|
Channel indices to use for false-color RGB visualization of HSI input (default: [0, 20, 40] for a simple false-color representation) |
None
|
max_samples
|
int
|
Maximum number of samples to log per batch (default: 4) |
4
|
log_every_n_batches
|
int
|
Log images every N batches to reduce TensorBoard size (default: 1, log every batch) |
1
|
Source code in cuvis_ai/node/pipeline_visualization.py
forward
¶
Create image artifacts for TensorBoard logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hsi_cube
|
Tensor
|
Input HSI cube [B, H, W, C] |
required |
mixer_output
|
Tensor
|
Mixer output (RGB-like) [B, H, W, 3] |
required |
ground_truth_mask
|
Tensor
|
Ground truth anomaly mask [B, H, W, 1] |
required |
adaclip_scores
|
Tensor
|
Anomaly scores [B, H, W, 1] |
required |
context
|
Context
|
Execution context with stage, epoch, batch_idx info |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, list[Artifact]]
|
Dictionary with "artifacts" key containing list of Artifact objects |
Source code in cuvis_ai/node/pipeline_visualization.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |