core
¤
bioimageio.core --- core functionality for BioImage.IO resources
The main focus on this library is to provide functionality to run prediction with BioImage.IO models, including standardized pre- and postprocessing operations. The BioImage.IO models (and other resources) are described by---and can be loaded with---the bioimageio.spec package.
See predict and predict_many for straight-forward model inference
and create_prediction_pipeline for finer control of the inference process.
Other notable bioimageio.core functionalities include:
- Testing BioImage.IO resources beyond format validation, e.g. by generating model outputs from test inputs.
See test_model or for arbitrary resource types test_description.
- Extending available model weight formats by converting existing ones, see add_weights.
- Creating and manipulating Samples consisting of tensors with associated statistics.
- Computing statistics on datasets (represented as sequences of samples), see compute_dataset_measures.
Modules:
| Name | Description |
|---|---|
__main__ |
|
axis |
|
backends |
|
block |
|
block_meta |
|
cli |
bioimageio CLI |
commands |
These functions are used in the bioimageio command line interface |
common |
|
dataset |
|
digest_spec |
|
io |
|
model_adapters |
DEPRECATED |
prediction |
|
proc_ops |
|
proc_setup |
|
sample |
|
stat_calculators |
|
stat_measures |
|
tensor |
|
utils |
|
weight_converters |
|
Classes:
| Name | Description |
|---|---|
PredictionPipeline |
Represents model computation including preprocessing and postprocessing |
Settings |
environment variables for bioimageio.spec and bioimageio.core |
Functions:
| Name | Description |
|---|---|
create_prediction_pipeline |
Creates prediction pipeline which includes: |
enable_determinism |
Seed and configure ML frameworks for maximum reproducibility. |
load_description_and_test |
Test a bioimage.io resource dynamically, |
test_description |
Test a bioimage.io resource dynamically, |
test_model |
Test model inference |
Attributes:
| Name | Type | Description |
|---|---|---|
Axis |
|
|
AxisId |
|
|
BlockMeta |
|
|
MemberId |
|
|
Sample |
|
|
Stat |
|
|
Tensor |
|
|
ValidationSummary |
|
|
__version__ |
|
|
add_weights |
|
|
build_description |
|
|
compute_dataset_measures |
|
|
create_model_adapter |
|
|
dump_description |
|
|
load_dataset_description |
|
|
load_description |
|
|
load_description_and_validate_format_only |
|
|
load_model |
alias of |
|
load_model_description |
|
|
load_resource |
alias of |
|
predict |
|
|
predict_many |
|
|
save_bioimageio_package |
|
|
save_bioimageio_package_as_folder |
|
|
save_bioimageio_yaml_only |
|
|
settings |
parsed environment variables for bioimageio.spec and bioimageio.core |
|
test_resource |
alias of |
|
validate_format |
|
compute_dataset_measures
module-attribute
¤
compute_dataset_measures = stat_calculators.compute_dataset_measures
load_dataset_description
module-attribute
¤
load_dataset_description = bioimageio.spec.load_dataset_description
load_description
module-attribute
¤
load_description = bioimageio.spec.load_description
-
API Reference
coreload_resource
load_description_and_validate_format_only
module-attribute
¤
load_description_and_validate_format_only = bioimageio.spec.load_description_and_validate_format_only
load_model_description
module-attribute
¤
load_model_description = bioimageio.spec.load_model_description
-
API Reference
coreload_model
save_bioimageio_package
module-attribute
¤
save_bioimageio_package = bioimageio.spec.save_bioimageio_package
save_bioimageio_package_as_folder
module-attribute
¤
save_bioimageio_package_as_folder = bioimageio.spec.save_bioimageio_package_as_folder
save_bioimageio_yaml_only
module-attribute
¤
save_bioimageio_yaml_only = bioimageio.spec.save_bioimageio_yaml_only
settings
module-attribute
¤
settings = Settings()
parsed environment variables for bioimageio.spec and bioimageio.core
PredictionPipeline
¤
PredictionPipeline(*, name: str, model_description: AnyModelDescr, preprocessing: List[Processing], postprocessing: List[Processing], model_adapter: ModelAdapter, default_ns: Optional[BlocksizeParameter] = None, default_blocksize_parameter: BlocksizeParameter = 10, default_batch_size: int = 1)
Represents model computation including preprocessing and postprocessing
Note: Ideally use the PredictionPipeline in a with statement
(as a context manager).
-
API Reference
corecreate_prediction_pipeline
-
API Reference
prediction
Methods:
| Name | Description |
|---|---|
__enter__ |
|
__exit__ |
|
apply_postprocessing |
apply postprocessing in-place, also updates samples stats |
apply_preprocessing |
apply preprocessing in-place, also updates sample stats |
get_output_sample_id |
|
load |
optional step: load model onto devices before calling forward if not using it as context manager |
predict_sample_block |
|
predict_sample_with_blocking |
predict a sample by splitting it into blocks according to the model and the |
predict_sample_with_fixed_blocking |
|
predict_sample_without_blocking |
predict a sample. |
unload |
free any device memory in use |
Attributes:
| Name | Type | Description |
|---|---|---|
model_description |
|
|
name |
|
Source code in src/bioimageio/core/_prediction_pipeline.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
__enter__
¤
__enter__()
Source code in src/bioimageio/core/_prediction_pipeline.py
114 115 116 | |
__exit__
¤
__exit__(exc_type, exc_val, exc_tb)
Source code in src/bioimageio/core/_prediction_pipeline.py
118 119 120 | |
apply_postprocessing
¤
apply_postprocessing(sample: Union[Sample, SampleBlock, SampleBlockWithOrigin]) -> None
apply postprocessing in-place, also updates samples stats
Source code in src/bioimageio/core/_prediction_pipeline.py
289 290 291 292 293 294 295 296 297 298 299 300 301 | |
apply_preprocessing
¤
apply_preprocessing(sample: Union[Sample, SampleBlockWithOrigin]) -> None
apply preprocessing in-place, also updates sample stats
Source code in src/bioimageio/core/_prediction_pipeline.py
284 285 286 287 | |
get_output_sample_id
¤
get_output_sample_id(input_sample_id: SampleId)
Source code in src/bioimageio/core/_prediction_pipeline.py
166 167 168 169 170 171 172 | |
load
¤
load()
optional step: load model onto devices before calling forward if not using it as context manager
Source code in src/bioimageio/core/_prediction_pipeline.py
303 304 305 306 307 | |
predict_sample_block
¤
predict_sample_block(sample_block: SampleBlockWithOrigin, skip_preprocessing: bool = False, skip_postprocessing: bool = False) -> SampleBlock
Source code in src/bioimageio/core/_prediction_pipeline.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
predict_sample_with_blocking
¤
predict_sample_with_blocking(sample: Sample, skip_preprocessing: bool = False, skip_postprocessing: bool = False, ns: Optional[Union[v0_5.ParameterizedSize_N, Mapping[Tuple[MemberId, AxisId], v0_5.ParameterizedSize_N]]] = None, batch_size: Optional[int] = None) -> Sample
predict a sample by splitting it into blocks according to the model and the ns parameter
Source code in src/bioimageio/core/_prediction_pipeline.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
predict_sample_with_fixed_blocking
¤
predict_sample_with_fixed_blocking(sample: Sample, input_block_shape: Mapping[MemberId, Mapping[AxisId, int]], *, skip_preprocessing: bool = False, skip_postprocessing: bool = False) -> Sample
Source code in src/bioimageio/core/_prediction_pipeline.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
predict_sample_without_blocking
¤
predict_sample_without_blocking(sample: Sample, skip_preprocessing: bool = False, skip_postprocessing: bool = False) -> Sample
predict a sample.
The sample's tensor shapes have to match the model's input tensor description.
If that is not the case, consider predict_sample_with_blocking
Source code in src/bioimageio/core/_prediction_pipeline.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
unload
¤
unload()
free any device memory in use
Source code in src/bioimageio/core/_prediction_pipeline.py
309 310 311 312 313 | |
Settings
¤
Bases: SpecSettings
flowchart TD
bioimageio.core.Settings[Settings]
bioimageio.spec._internal._settings.Settings[Settings]
bioimageio.spec._internal._settings.Settings --> bioimageio.core.Settings
click bioimageio.core.Settings href "" "bioimageio.core.Settings"
click bioimageio.spec._internal._settings.Settings href "" "bioimageio.spec._internal._settings.Settings"
environment variables for bioimageio.spec and bioimageio.core
Methods:
| Name | Description |
|---|---|
__setattr__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
CI |
Annotated[Union[bool, str], Field(alias=CI)]
|
Wether or not the execution happens in a continuous integration (CI) environment. |
allow_pickle |
bool
|
Sets the |
cache_path |
Path
|
bioimageio cache location |
collection_http_pattern |
str
|
A pattern to map bioimageio IDs to bioimageio.yaml URLs. |
disk_cache |
|
|
github_auth |
|
|
github_token |
Optional[str]
|
GitHub token for API requests |
github_username |
Optional[str]
|
GitHub username for API requests |
http_timeout |
float
|
Timeout in seconds for http requests. |
huggingface_http_pattern |
str
|
A pattern to map huggingface repo IDs to bioimageio.yaml URLs. |
hypha_upload |
str
|
URL to the upload endpoint for bioimageio resources. |
hypha_upload_token |
Optional[str]
|
Hypha API token to use for uploads. |
id_map |
str
|
URL to bioimageio id_map.json to resolve resource IDs. |
id_map_draft |
str
|
URL to bioimageio id_map_draft.json to resolve draft IDs ending with '/draft'. |
keras_backend |
Annotated[Literal['torch', 'tensorflow', 'jax'], Field(alias=KERAS_BACKEND)]
|
|
log_warnings |
bool
|
Log validation warnings to console. |
model_config |
|
|
perform_io_checks |
bool
|
Wether or not to perform validation that requires file io, |
resolve_draft |
bool
|
Flag to resolve draft resource versions following the pattern |
user_agent |
Optional[str]
|
user agent for http requests |
CI
class-attribute
instance-attribute
¤
Wether or not the execution happens in a continuous integration (CI) environment.
allow_pickle
class-attribute
instance-attribute
¤
allow_pickle: bool = False
Sets the allow_pickle argument for numpy.load()
cache_path
class-attribute
instance-attribute
¤
cache_path: Path = Path(platformdirs.user_cache_dir('bioimageio'))
bioimageio cache location
collection_http_pattern
class-attribute
instance-attribute
¤
collection_http_pattern: str = 'https://hypha.aicell.io/bioimage-io/artifacts/{bioimageio_id}/files/rdf.yaml'
A pattern to map bioimageio IDs to bioimageio.yaml URLs.
Notes:
- '{bioimageio_id}' is replaced with user query,
e.g. "affable-shark" when calling load_description("affable-shark").
- This method takes precedence over resolving via id_map.
- If this endpoints fails, we fall back to id_map.
github_token
class-attribute
instance-attribute
¤
github_token: Optional[str] = None
GitHub token for API requests
github_username
class-attribute
instance-attribute
¤
github_username: Optional[str] = None
GitHub username for API requests
http_timeout
class-attribute
instance-attribute
¤
http_timeout: float = 10.0
Timeout in seconds for http requests.
huggingface_http_pattern
class-attribute
instance-attribute
¤
huggingface_http_pattern: str = 'https://huggingface.co/{repo_id}/resolve/{branch}/package/bioimageio.yaml'
A pattern to map huggingface repo IDs to bioimageio.yaml URLs.
Notes:
- Used for loading source strings of the form "huggingface/{user_or_org}/{resource_id}[/{version}]"
- example use: load_description("huggingface/fynnbe/ambitious-sloth/1.3")
- A given version {version} is mapped to a branch name "v{version}", e.g. "v1.3".
- If no version is provided the "main" branch is used.
- This method takes precedence over resolving via id_map.
- If this endpoints fails, we fall back to id_map.
hypha_upload
class-attribute
instance-attribute
¤
hypha_upload: str = 'https://hypha.aicell.io/public/services/artifact-manager/create'
URL to the upload endpoint for bioimageio resources.
hypha_upload_token
class-attribute
instance-attribute
¤
hypha_upload_token: Optional[str] = None
Hypha API token to use for uploads.
By setting this token you agree to our terms of service at https://bioimage.io/#/toc.
How to obtain a token
- Login to https://bioimage.io
- Generate a new token at https://bioimage.io/#/api?tab=hypha-rpc
id_map
class-attribute
instance-attribute
¤
id_map: str = 'https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/id_map.json'
URL to bioimageio id_map.json to resolve resource IDs.
id_map_draft
class-attribute
instance-attribute
¤
id_map_draft: str = 'https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/id_map_draft.json'
URL to bioimageio id_map_draft.json to resolve draft IDs ending with '/draft'.
keras_backend
class-attribute
instance-attribute
¤
keras_backend: Annotated[Literal['torch', 'tensorflow', 'jax'], Field(alias=KERAS_BACKEND)] = 'torch'
log_warnings
class-attribute
instance-attribute
¤
log_warnings: bool = True
Log validation warnings to console.
model_config
class-attribute
instance-attribute
¤
model_config = SettingsConfigDict(env_prefix='BIOIMAGEIO_', env_file='.env', env_file_encoding='utf-8')
perform_io_checks
class-attribute
instance-attribute
¤
perform_io_checks: bool = True
Wether or not to perform validation that requires file io, e.g. downloading a remote files.
Existence of any local absolute file paths is still being checked.
resolve_draft
class-attribute
instance-attribute
¤
resolve_draft: bool = True
Flag to resolve draft resource versions following the pattern
Note that anyone may stage a new draft and that such a draft version may not have been reviewed yet. Set this flag to False to avoid this potential security risk and disallow loading draft versions.
user_agent
class-attribute
instance-attribute
¤
user_agent: Optional[str] = None
user agent for http requests
__setattr__
¤
__setattr__(name: str, value: Any)
Source code in bioimageio/spec/_internal/_settings.py
31 32 33 34 35 36 37 38 39 | |
create_prediction_pipeline
¤
create_prediction_pipeline(bioimageio_model: AnyModelDescr, *, devices: Optional[Sequence[str]] = None, weight_format: Optional[SupportedWeightsFormat] = None, weights_format: Optional[SupportedWeightsFormat] = None, dataset_for_initial_statistics: Iterable[Union[Sample, Sequence[Tensor]]] = tuple(), keep_updating_initial_dataset_statistics: bool = False, fixed_dataset_statistics: Mapping[DatasetMeasure, MeasureValue] = MappingProxyType({}), model_adapter: Optional[ModelAdapter] = None, ns: Optional[BlocksizeParameter] = None, default_blocksize_parameter: BlocksizeParameter = 10, **deprecated_kwargs: Any) -> PredictionPipeline
Creates prediction pipeline which includes: * computation of input statistics * preprocessing * model prediction * computation of output statistics * postprocessing
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
AnyModelDescr
|
A bioimageio model description. |
required |
|
Optional[Sequence[str]]
|
(optional) |
None
|
|
Optional[SupportedWeightsFormat]
|
deprecated in favor of weights_format |
None
|
|
Optional[SupportedWeightsFormat]
|
(optional) Use a specific weights_format rather than
choosing one automatically.
A corresponding |
None
|
|
Iterable[Union[Sample, Sequence[Tensor]]]
|
(optional) If preprocessing steps require input dataset statistics, dataset_for_initial_statistics allows you to specifcy a dataset from which these statistics are computed. |
tuple()
|
|
bool
|
(optional) Set to |
False
|
|
Mapping[DatasetMeasure, MeasureValue]
|
(optional) Allows you to specify a mapping of
|
MappingProxyType({})
|
|
Optional[ModelAdapter]
|
(optional) Allows you to use a custom model_adapter instead of creating one according to the present/selected weights_format. |
None
|
|
Optional[BlocksizeParameter]
|
deprecated in favor of default_blocksize_parameter |
None
|
|
BlocksizeParameter
|
Allows to control the default block size for
blockwise predictions, see |
10
|
Source code in src/bioimageio/core/_prediction_pipeline.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
enable_determinism
¤
enable_determinism(mode: Literal['seed_only', 'full'] = 'full', weight_formats: Optional[Sequence[SupportedWeightsFormat]] = None)
Seed and configure ML frameworks for maximum reproducibility. May degrade performance. Only recommended for testing reproducibility!
Seed any random generators and (if mode=="full") request ML frameworks to use deterministic algorithms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Literal['seed_only', 'full']
|
determinism mode - 'seed_only' -- only set seeds, or - 'full' determinsm features (might degrade performance or throw exceptions) |
'full'
|
|
Optional[Sequence[SupportedWeightsFormat]]
|
Limit deep learning importing deep learning frameworks based on weight_formats. E.g. this allows to avoid importing tensorflow when testing with pytorch. |
None
|
Notes
Source code in src/bioimageio/core/_resource_tests.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
load_description_and_test
¤
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Literal['latest'], weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Literal['model'], sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[ModelDescr, InvalidDescr]
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Literal['latest'], weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Literal['dataset'], sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[DatasetDescr, InvalidDescr]
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Literal['latest'], weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Optional[str] = None, sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[LatestResourceDescr, InvalidDescr]
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Union[FormatVersionPlaceholder, str] = DISCOVER, weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Literal['model'], sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[AnyModelDescr, InvalidDescr]
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Union[FormatVersionPlaceholder, str] = DISCOVER, weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Literal['dataset'], sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[AnyDatasetDescr, InvalidDescr]
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Union[FormatVersionPlaceholder, str] = DISCOVER, weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Optional[str] = None, sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[ResourceDescr, InvalidDescr]
load_description_and_test(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Union[FormatVersionPlaceholder, str] = DISCOVER, weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Optional[str] = None, sha256: Optional[Sha256] = None, stop_early: bool = True, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> Union[ResourceDescr, InvalidDescr]
Test a bioimage.io resource dynamically, for example run prediction of test tensors for models.
See test_description for more details.
Returns:
| Type | Description |
|---|---|
Union[ResourceDescr, InvalidDescr]
|
A (possibly invalid) resource description object
with a populated |
Source code in src/bioimageio/core/_resource_tests.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | |
test_description
¤
test_description(source: Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent], *, format_version: Union[FormatVersionPlaceholder, str] = 'discover', weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[Sequence[str]] = None, determinism: Literal['seed_only', 'full'] = 'seed_only', expected_type: Optional[str] = None, sha256: Optional[Sha256] = None, stop_early: bool = True, runtime_env: Union[Literal['currently-active', 'as-described'], Path, BioimageioCondaEnv] = 'currently-active', run_command: Callable[[Sequence[str]], None] = default_run_command, working_dir: Optional[Union[os.PathLike[str], str]] = None, **deprecated: Unpack[DeprecatedKwargs]) -> ValidationSummary
Test a bioimage.io resource dynamically, for example run prediction of test tensors for models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[ResourceDescr, PermissiveFileSource, BioimageioYamlContent]
|
model description source. |
required |
|
Optional[SupportedWeightsFormat]
|
Weight format to test. Default: All weight formats present in source. |
None
|
|
Optional[Sequence[str]]
|
Devices to test with, e.g. 'cpu', 'cuda'. Default (may be weight format dependent): ['cuda'] if available, ['cpu'] otherwise. |
None
|
|
Literal['seed_only', 'full']
|
Modes to improve reproducibility of test outputs. |
'seed_only'
|
|
Optional[str]
|
Assert an expected resource description |
None
|
|
Optional[Sha256]
|
Expected SHA256 value of source.
(Ignored if source already is a loaded |
None
|
|
bool
|
Do not run further subtests after a failed one. |
True
|
|
Union[Literal['currently-active', 'as-described'], Path, BioimageioCondaEnv]
|
(Experimental feature!) The Python environment to run the tests in
- |
'currently-active'
|
|
Callable[[Sequence[str]], None]
|
(Experimental feature!) Function to execute (conda) terminal commands in a subprocess.
The function should raise an exception if the command fails.
run_command is ignored if runtime_env is |
default_run_command
|
|
Optional[Union[os.PathLike[str], str]]
|
(for debugging) directory to save any temporary files (model packages, conda environments, test summaries). Defaults to a temporary directory. |
None
|
-
API Reference
coretest_resource
Source code in src/bioimageio/core/_resource_tests.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
test_model
¤
test_model(source: Union[v0_4.ModelDescr, v0_5.ModelDescr, PermissiveFileSource], weight_format: Optional[SupportedWeightsFormat] = None, devices: Optional[List[str]] = None, *, determinism: Literal['seed_only', 'full'] = 'seed_only', sha256: Optional[Sha256] = None, stop_early: bool = True, **deprecated: Unpack[DeprecatedKwargs]) -> ValidationSummary
Test model inference
Source code in src/bioimageio/core/_resource_tests.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |