Make the validation sample-plot count configurable (#830) - #880
Merged
Merged
Conversation
The detection validator stored a hardcoded 8 sample images for the sample-image plot. - ValidationConfig.plot_samples / TrainConfig.plot_samples, on both CLI commands. 0 disables the plot, -1 keeps every validated image, default stays 8. - collection stays bounded by the requested count, so a small budget does not hold images for the whole run. It is a plotting budget only: every image is still scored and the metrics are unchanged at any setting.
| # How many validated images are kept for the sample-image plot. | ||
| # 0 disables that plot, -1 keeps every image. This is a plotting | ||
| # budget only: it never changes which images are scored (#830). | ||
| plot_samples: int = field(default=DEFAULT_PLOT_SAMPLES, kw_only=True) |
There was a problem hiding this comment.
The shared plot_samples option is accepted for pose validation, but PoseValidator still hardcodes an eight-image limit. As a result, model.val(plot_samples=0) still produces pose sample plots, while values above eight or -1 still collect only eight images. Route the configured budget into pose sample collection or reject the option for that task.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…samples # Conflicts: # CHANGELOG.md # libreyolo/cli/commands/val.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #830.
What changed
plot_samplesonValidationConfigandTrainConfig, and on thevalandtrainCLI commands. It replaces the hardcoded_N_VAL_SAMPLES = 8in thedetection validator.
0disables the sample-image plot,-1keeps every validated image, defaultstays
8.hold images in memory for the whole run.
-1on a large val set deliberatelydoes; that is what the reporter asked for and the help text says so.
It cannot change the metrics
That was the explicit constraint on this issue, so it is what the tests are
built around. The budget is consulted in exactly one place, inside
_track_plots_data, which is already separate from scoring. The tests drivethe real
_track_plots_dataat budgets0 / 1 / 8 / 20 / -1and assert theconfusion matrix receives an identical call sequence every time, with only the
sample buffer length differing. Every image is still processed at every
setting, including
plot_samples=0.Naming
The reporter suggested
n_samples. I usedplot_samplesinstead, becausen_samplesreads like "how many images to validate", which is exactly themisreading this issue warns against. No ecosystem equivalent exists to match
(checked public docs only).
Verification
tests/unit/test_val_plot_samples.py: accepted and rejectedvalues, default equals the old hardcoded 8, budget arithmetic, metric
invariance as above, a legacy config without the field keeping old behavior,
and both CLI surfaces forwarding the value.
pytest tests/unit -k "val or plot or coco or config or cli or trainer":1631 passed, 48 skipped.
budget decision and the plumbing, not the plot image itself.
Contributor note
MARIANOCEREDA offered to take this on 2026-08-27 and was invited to. No PR
appeared in the three weeks since. Close this in favour of theirs if they turn
up with one.
Code provenance
Original code written for this PR. No third-party code was ported, adapted or
derived.
The PR appears safe to merge; the previously outstanding pose-budget behavior is now fixed and no new actionable failures remain.
Summary
The PR replaces the fixed validation sample-plot limit with a validated
plot_samplesconfiguration shared by training, standalone validation, detection, and pose workflows.0to disable collection, and-1to retain every validated image.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR CLI[train / val CLI] --> Config[TrainConfig / ValidationConfig] API[Python train / val API] --> Config Config --> Validation[Detection or Pose Validator] Validation --> Scoring[Score every image] Validation --> Budget{plot_samples} Budget -->|0| None[Keep no plot samples] Budget -->|positive N| Bounded[Keep at most N samples] Budget -->|-1| All[Keep every sample]Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/dev..."