spacr.model_check¶
Check whether a model is compatible with spaCR and the chosen classes.
The check runs before training and answers 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 fails silently: a two-class head on a three-class problem trains without error and is wrong about every object of the third class.
A custom model that loads supersedes model_type. No separate flag
selects between them.
Classes¶
Result of a model compatibility check. |
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]¶
Result of a model compatibility check.
- 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; problems are reported in the returned
ModelReport.
- 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 takes precedence; otherwisemodel_typeis used.