spacr.model_check¶
Is this model compatible with spaCR, and with the classes chosen?
Clicking a model should say whether it will work before an hour of training finds out. Three questions, in the order they can fail:
Can it be LOADED at all? A custom path may hold a checkpoint saved by a different framework, a state dict with no architecture, or a corrupt file.
Does it take the INPUT this dataset produces – the right number of image channels, at the chosen size?
Does it produce the right number of CLASSES?
The third is the one that silently half-works: a two-class head on a three-class problem trains happily and is wrong about every object of the third class.
A custom model that loads supersedes model_type. There is no boolean
saying which to believe, because a path that holds a working model is a
complete answer on its own and a flag that disagreed with it would just be a
second thing to get wrong.
Classes¶
What was found. |
Functions¶
|
Whether the chosen model can train on the chosen data and classes. |
|
How many image channels this dataset will hand the model. |
|
How many classes the training set will have. |
|
|
Module Contents¶
- class spacr.model_check.ModelReport[source]¶
What was found.
okfirst, because it is the answer.- Parameters:
ok – whether the compatibility check found no blocking problem.
source – display identifier for the checked model: a built-in name, custom-file basename, or
"no model".problems – blocking diagnostic messages used by the unsuccessful summary.
notes – non-blocking compatibility facts retained separately and appended to the summary when
okis true.channels – dataset input-channel count requested by the settings, or
Nonewhen it cannot be determined.classes – requested class count derived from the class definitions, or
Nonewhen it cannot be determined.
- spacr.model_check.check_model(settings: Mapping[str, Any]) ModelReport[source]¶
Whether the chosen model can train on the chosen data and classes.
- Parameters:
settings – classification settings to validate against the model.
Never raises: this runs from a click, and a dialog that crashes the screen is a worse answer than one that says what is wrong.
- spacr.model_check.expected_channels(settings: Mapping[str, Any]) int | None[source]¶
How many image channels this dataset will hand the model.
- Parameters:
settings – classification settings containing channel declarations.
- spacr.model_check.expected_classes(settings: Mapping[str, Any]) int | None[source]¶
How many classes the training set will have.
- Parameters:
settings – classification settings containing class definitions.
- spacr.model_check.resolve_model_source(settings: Mapping[str, Any]) Tuple[str, str][source]¶
(kind, name)for the model that will actually be used.- Parameters:
settings – classification settings containing model choices.
kindis'custom'or'builtin'. A custom path that EXISTS wins: the oldcustom_modelboolean could disagree with the path beside it, and then which one won depended on which reader you asked.