Skip to content

Add tensorboard support for segmentation metrics.#412

Open
Abdul-Mukit wants to merge 1 commit intoroboflow:developfrom
Abdul-Mukit:add_mask_metrics_to_tensorboard
Open

Add tensorboard support for segmentation metrics.#412
Abdul-Mukit wants to merge 1 commit intoroboflow:developfrom
Abdul-Mukit:add_mask_metrics_to_tensorboard

Conversation

@Abdul-Mukit
Copy link
Contributor

Description

Closes: #411
While training RFDETRSegPreview, the plots in tensorboard still only contain metrics related to BBox. Plots of segmentation metrics are missing.
In order to support this, the class MetricsTensorBoardSink needs to be enhanced.

Expected behavior when training segmentation models:

Image Image Image

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

Google Colab.

Any specific deployment considerations

None

Docs

None

@Abdul-Mukit
Copy link
Contributor Author

Hi @isaacrob-roboflow do you have any comments on this PR?
I am using this feature for my experiments. It would be helpful if this were part of the rfdeter repo.
Please let me know if you want any modifications. Thank you.

@Borda Borda added the enhancement New feature or request label Jan 22, 2026
@Borda Borda requested a review from isaacrob as a code owner February 11, 2026 15:57
@Borda Borda force-pushed the develop branch 4 times, most recently from 60b16c1 to 523f9df Compare February 14, 2026 06:46
@Borda Borda requested review from Copilot and removed request for isaacrob-roboflow February 19, 2026 13:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds TensorBoard logging support for segmentation metrics in RF-DETR. When training segmentation models (e.g., RFDETRSegPreview), mask-related metrics (AP50_90, AP50, AR50_90) are now logged to TensorBoard alongside the existing bounding box metrics. The change also renames the bbox metric paths from "Metrics/" to "Metrics-BBox/" for clarity and consistency.

Changes:

  • Added segmentation mask metrics logging to TensorBoard (test_coco_eval_masks and ema_test_coco_eval_masks)
  • Renamed bbox metrics paths from "Metrics/" to "Metrics-BBox/" for better organization
  • New mask metrics logged under "Metrics-Masks/" path structure

Comment on lines +168 to +190
if 'test_coco_eval_masks' in values:
coco_eval = values['test_coco_eval_masks']
ap50_90 = safe_index(coco_eval, 0)
ap50 = safe_index(coco_eval, 1)
ar50_90 = safe_index(coco_eval, 8)
if ap50_90 is not None:
self.writer.add_scalar("Metrics-Masks/Base/AP50_90", ap50_90, epoch)
if ap50 is not None:
self.writer.add_scalar("Metrics-Masks/Base/AP50", ap50, epoch)
if ar50_90 is not None:
self.writer.add_scalar("Metrics-Masks/Base/AR50_90", ar50_90, epoch)

if 'ema_test_coco_eval_masks' in values:
ema_coco_eval = values['ema_test_coco_eval_masks']
ema_ap50_90 = safe_index(ema_coco_eval, 0)
ema_ap50 = safe_index(ema_coco_eval, 1)
ema_ar50_90 = safe_index(ema_coco_eval, 8)
if ema_ap50_90 is not None:
self.writer.add_scalar("Metrics-Masks/EMA/AP50_90", ema_ap50_90, epoch)
if ema_ap50 is not None:
self.writer.add_scalar("Metrics-Masks/EMA/AP50", ema_ap50, epoch)
if ema_ar50_90 is not None:
self.writer.add_scalar("Metrics-Masks/EMA/AR50_90", ema_ar50_90, epoch)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The segmentation metrics logging in MetricsTensorBoardSink is implemented correctly, but MetricsWandBSink (lines 200-267) also needs the same support for consistency. When training segmentation models with W&B logging enabled, users will not see mask metrics logged to Weights & Biases.

Consider adding the same segmentation metrics support to MetricsWandBSink with the same pattern. The implementation would be similar but using the wandb log_dict pattern instead of writer.add_scalar. This ensures feature parity across all logging backends.

Copilot uses AI. Check for mistakes.
Comment on lines +150 to +166
self.writer.add_scalar("Metrics-BBox/Base/AP50_90", ap50_90, epoch)
if ap50 is not None:
self.writer.add_scalar("Metrics/Base/AP50", ap50, epoch)
self.writer.add_scalar("Metrics-BBox/Base/AP50", ap50, epoch)
if ar50_90 is not None:
self.writer.add_scalar("Metrics/Base/AR50_90", ar50_90, epoch)
self.writer.add_scalar("Metrics-BBox/Base/AR50_90", ar50_90, epoch)

if 'ema_test_coco_eval_bbox' in values:
ema_coco_eval = values['ema_test_coco_eval_bbox']
ema_ap50_90 = safe_index(ema_coco_eval, 0)
ema_ap50 = safe_index(ema_coco_eval, 1)
ema_ar50_90 = safe_index(ema_coco_eval, 8)
if ema_ap50_90 is not None:
self.writer.add_scalar("Metrics/EMA/AP50_90", ema_ap50_90, epoch)
self.writer.add_scalar("Metrics-BBox/EMA/AP50_90", ema_ap50_90, epoch)
if ema_ap50 is not None:
self.writer.add_scalar("Metrics/EMA/AP50", ema_ap50, epoch)
self.writer.add_scalar("Metrics-BBox/EMA/AP50", ema_ap50, epoch)
if ema_ar50_90 is not None:
self.writer.add_scalar("Metrics/EMA/AR50_90", ema_ar50_90, epoch)
self.writer.add_scalar("Metrics-BBox/EMA/AR50_90", ema_ar50_90, epoch)
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent metric naming between TensorBoard and W&B logging. MetricsTensorBoardSink uses "Metrics-BBox/" prefix (lines 150, 152, 154, 162, 164, 166) while MetricsWandBSink uses "Metrics/" prefix (lines 243, 245, 247, 255, 257, 259).

For consistency across logging backends, consider updating MetricsWandBSink to also use "Metrics-BBox/" instead of "Metrics/" when logging bbox metrics, matching the TensorBoard naming convention established in this PR.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request has conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tensorboard support for segmentation metrics.

2 participants

Comments