Add optional segmentation metrics plots to MetricsPlotSink.#410
Add optional segmentation metrics plots to MetricsPlotSink.#410Abdul-Mukit wants to merge 3 commits intoroboflow:developfrom
Conversation
|
Hi @isaacrob-roboflow do you have any comments on this PR? |
60b16c1 to
523f9df
Compare
|
I'll resume this. Please let me know if not needed anymore or if it causes any conflicts with your plans. |
a6e6ca0 to
0485141
Compare
|
@Abdul-Mukit thank you for this PR, could you pls revisit the updated codebase, pls... |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #410 +/- ##
=======================================
Coverage 75% 75%
=======================================
Files 91 92 +1
Lines 6836 6962 +126
=======================================
+ Hits 5109 5215 +106
- Misses 1727 1747 +20 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds an automatic post-training metrics plot generator to RF-DETR Lightning training runs, with the goal of including segmentation metrics (when present) in metrics_plot.png.
Changes:
- Introduces
MetricsPlotCallbackto parsemetrics.csvand writemetrics_plot.png, expanding the plot layout when segmentation metrics exist. - Wires
MetricsPlotCallbackintobuild_trainer()’s callback stack so it runs after training. - Exports the new callback from
rfdetr.training.callbacks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/rfdetr/training/trainer.py |
Registers MetricsPlotCallback in the default PTL callback stack. |
src/rfdetr/training/callbacks/metrics_plot.py |
New callback that reads CSVLogger output and generates bbox-only or bbox+segm plots. |
src/rfdetr/training/callbacks/__init__.py |
Exposes MetricsPlotCallback via the callbacks package API. |
You can also share your feedback on Copilot code review. Take the survey.
| class MetricsPlotCallback(Callback): | ||
| """Read ``metrics.csv`` written by CSVLogger and save a metrics figure. | ||
|
|
||
| Generates a 2×2 grid for detection-only models, or a 3×2 grid when | ||
| segmentation metrics are present in the log. | ||
|
|
||
| The plot is saved to ``{output_dir}/metrics_plot.png`` after training ends. | ||
| """ | ||
|
|
||
| def on_train_end(self, trainer: Any, pl_module: Any) -> None: | ||
| """Save the metrics plot when training completes.""" | ||
| csv_path = self._find_csv(trainer) | ||
| if csv_path is None: | ||
| return | ||
| history = self._read_csv(csv_path) | ||
| if not history: | ||
| return | ||
| output_dir = Path(trainer.default_root_dir) | ||
| self._save_plot(history, output_dir) | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
I'll close the MR. Apologies for the delay. I saw your comment on the issue. |
Description
Closes: #409
After completing training with RFDETRSegPreview, the plots in
metrics_plot.pngstill only contain metrics related to BBox. Plots of segmentation metrics are missing.Changes:
Current behavior of MetricsPlotSink:

Even when training a RFDETRSegPreview, we only get plots for BBox metrics.
Updated behavior of MetricsPlotSink:

Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
Tested on Google Colab for both RFDETRMedium and RFDETRSegPreview.
Any specific deployment considerations
None
Docs
None