tracebloc 1.2.80__tar.gz → 1.2.82__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tracebloc-1.2.80 → tracebloc-1.2.82}/PKG-INFO +4 -4
- {tracebloc-1.2.80 → tracebloc-1.2.82}/pyproject.toml +4 -4
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_linking.py +6 -6
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/training_versions.py +13 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/inference.py +7 -5
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/link_model_dataset.py +45 -61
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/augmentation.py +20 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/converted.py +19 -5
- tracebloc-1.2.82/tracebloc/training/image_channels.py +107 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/plan.py +12 -4
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/subdataset.py +68 -7
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/submitter.py +4 -1
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/constants.py +9 -3
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/general_utils.py +3 -3
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc.egg-info/PKG-INFO +4 -4
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc.egg-info/SOURCES.txt +1 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc.egg-info/requires.txt +5 -3
- {tracebloc-1.2.80 → tracebloc-1.2.82}/MANIFEST.in +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/README.md +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/license.txt +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/setup.cfg +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_deprecation.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_framework_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_http_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_link_answer.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_link_regeneration.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_raw_width_note.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_stored_link.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/_upload_conversion.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/checks.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/client.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/config.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/contracts/stage_urls.v1.json +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/contracts/stage_urls.v1.source.json +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/contracts/survival_payload.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/contracts/training_requirements.source.json +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/contracts/training_requirements.txt +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/acceptance.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/hf/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/hf/_build.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/hf/_model_type.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/tabular.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/vision/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/families/vision/_matching.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/gate.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/heads.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/interfaces.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/licence/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/licence/spdx.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/outputs.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/arguments.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/assemble.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/checkpoint.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/gate_rules.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/generate.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/head.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/import_check.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/layer0.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/live.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/model_class.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/remote.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/repo.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/shake.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/owncode/source_tree.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/package.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/report.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/convert/tokenizers.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/env_login.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/exceptions.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/fetch.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/library_fetch.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/lifelines_weights.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/_partials.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/embeddings.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/nlp_finetune.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/nlp_generative.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/survival.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/tabular_timeseries.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/notebook/templates/vision_from_scratch.tpl +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/raw_mode.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/raw_mode_frame.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/raw_mode_seed.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/raw_mode_survival.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/raw_mode_torch.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/seed_weights.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/callbacks.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/features.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/image_size.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/lora.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/lora_validation.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/loss.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/memory_estimate.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/preprocessing.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/shape.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/training/summary.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/lifelines_time_to_event.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/model_upload.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/scikit_survival_time_to_event.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/sequence_length.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/skl_tabular_base.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/skl_tabular_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/skl_tabular_regression.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/statistical_base.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/survival_base.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_causal_language_modeler.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_embeddings.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_image_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_key_point_detector.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_masked_language_modeler.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_nlp_base.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_object_detector.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_semantic_segmentation.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_sentence_pair_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_seq2seq_modeler.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_tabular_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_tabular_regression.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_text_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_time_series_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_time_series_forecaster.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_time_to_event.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/torch_token_classifier.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/weight_loaders.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/upload/weights_parts.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/user.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/class_order.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/custom_loss_probe.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/detection_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/entry_point.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/feature_dict.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/key_point_detection_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/registry.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/safetensors_io.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/semantic_segmentation_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/tabular_classification_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/tabular_custom_loss_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/tabular_regression_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/text_classification_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/time_series_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/time_to_event_utils.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/utils/warnings_once.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/__init__.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/checker.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/header_rules.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/lifelines_checks.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/pytorch_checks.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/rewriter.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/scikit_survival_checks.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc/validation/sklearn_checks.py +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc.egg-info/dependency_links.txt +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc.egg-info/top_level.txt +0 -0
- {tracebloc-1.2.80 → tracebloc-1.2.82}/tracebloc_package/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tracebloc
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.82
|
|
4
4
|
Summary: Build AI with anyone. On data that can't move. SDK for the tracebloc collaborative AI workspace.
|
|
5
5
|
Author-email: tracebloc <lukas@tracebloc.io>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -51,8 +51,8 @@ Requires-Dist: scikit-survival>=0.27.0; extra == "scikit-survival"
|
|
|
51
51
|
Provides-Extra: all
|
|
52
52
|
Requires-Dist: tracebloc[lifelines,pytorch,scikit-survival,sklearn]; extra == "all"
|
|
53
53
|
Provides-Extra: training
|
|
54
|
-
Requires-Dist: numpy==2.1.3; extra == "training"
|
|
55
|
-
Requires-Dist: pandas==2.3.0; extra == "training"
|
|
54
|
+
Requires-Dist: numpy==2.1.3; python_version < "3.14" and extra == "training"
|
|
55
|
+
Requires-Dist: pandas==2.3.0; python_version < "3.14" and extra == "training"
|
|
56
56
|
Requires-Dist: psutil==7.0.0; extra == "training"
|
|
57
57
|
Requires-Dist: pillow==13.0.0; extra == "training"
|
|
58
58
|
Requires-Dist: safetensors>=0.4.3; extra == "training"
|
|
@@ -61,7 +61,7 @@ Requires-Dist: torchvision==0.29.1; extra == "training"
|
|
|
61
61
|
Requires-Dist: torchmetrics==1.9.0; extra == "training"
|
|
62
62
|
Requires-Dist: timm==1.0.26; extra == "training"
|
|
63
63
|
Requires-Dist: pycox==0.3.0; extra == "training"
|
|
64
|
-
Requires-Dist: pytorch-forecasting==1.4.0; extra == "training"
|
|
64
|
+
Requires-Dist: pytorch-forecasting==1.4.0; python_version < "3.14" and extra == "training"
|
|
65
65
|
Requires-Dist: transformers==5.16.1; extra == "training"
|
|
66
66
|
Requires-Dist: peft==0.19.1; extra == "training"
|
|
67
67
|
Requires-Dist: torchao==0.17.0; extra == "training"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tracebloc"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.82"
|
|
8
8
|
description = "Build AI with anyone. On data that can't move. SDK for the tracebloc collaborative AI workspace."
|
|
9
9
|
license = "MIT"
|
|
10
10
|
license-files = ["license.txt"]
|
|
@@ -119,8 +119,8 @@ all = [
|
|
|
119
119
|
# one moves without the other.
|
|
120
120
|
# BEGIN training extra: generated by scripts/sync_training_extra.py, do not edit
|
|
121
121
|
training = [
|
|
122
|
-
"numpy==2.1.3",
|
|
123
|
-
"pandas==2.3.0",
|
|
122
|
+
"numpy==2.1.3; python_version < '3.14'",
|
|
123
|
+
"pandas==2.3.0; python_version < '3.14'",
|
|
124
124
|
"psutil==7.0.0",
|
|
125
125
|
"pillow==13.0.0",
|
|
126
126
|
"safetensors>=0.4.3",
|
|
@@ -129,7 +129,7 @@ training = [
|
|
|
129
129
|
"torchmetrics==1.9.0",
|
|
130
130
|
"timm==1.0.26",
|
|
131
131
|
"pycox==0.3.0",
|
|
132
|
-
"pytorch-forecasting==1.4.0",
|
|
132
|
+
"pytorch-forecasting==1.4.0; python_version < '3.14'",
|
|
133
133
|
"transformers==5.16.1",
|
|
134
134
|
"peft==0.19.1",
|
|
135
135
|
"torchao==0.17.0",
|
|
@@ -34,7 +34,7 @@ from ._link_answer import compared_keys
|
|
|
34
34
|
from ._link_regeneration import regenerated_for_link # noqa: F401
|
|
35
35
|
from .exceptions import APIError, DatasetLinkingError
|
|
36
36
|
from .training.image_size import image_size_warning
|
|
37
|
-
from .training.subdataset import dataset_record_total
|
|
37
|
+
from .training.subdataset import any_held, dataset_record_total
|
|
38
38
|
from .utils.class_order import class_order_text
|
|
39
39
|
from .utils.general_utils import get_images_count, resource_fit_warning
|
|
40
40
|
from .validation.sklearn_checks import non_averageable_estimator_reason
|
|
@@ -341,12 +341,12 @@ def _apply_link_success(
|
|
|
341
341
|
total_images = content["total_images"]
|
|
342
342
|
num_classes = content["dataset_classes"]
|
|
343
343
|
class_names = content["class_names"]
|
|
344
|
-
# RECORDS, not the label sum: ``class_names`` counts tags /
|
|
345
|
-
#
|
|
346
|
-
#
|
|
347
|
-
#
|
|
344
|
+
# RECORDS, not the label sum: ``class_names`` counts tags / boxes for
|
|
345
|
+
# token_classification / object_detection, several per record, while every
|
|
346
|
+
# bound and draw is in records. Unreadable ``total_images`` keeps the label
|
|
347
|
+
# sum (same stance as the record bound); a held count (``is_held``) leaves None.
|
|
348
348
|
total_dataset_size = dataset_record_total(total_images)
|
|
349
|
-
if total_dataset_size is None:
|
|
349
|
+
if total_dataset_size is None and not any_held(total_images, class_names):
|
|
350
350
|
total_dataset_size = get_images_count(class_names)
|
|
351
351
|
feature_modification = content["allow_feature_modification"]
|
|
352
352
|
table_name = content["table_name"]
|
|
@@ -14,6 +14,7 @@ from __future__ import annotations
|
|
|
14
14
|
|
|
15
15
|
import ast
|
|
16
16
|
import re
|
|
17
|
+
import sys
|
|
17
18
|
from importlib import metadata
|
|
18
19
|
from pathlib import Path
|
|
19
20
|
from typing import Iterable, Mapping
|
|
@@ -52,6 +53,11 @@ TRAINING_LIBRARIES: Mapping[str, tuple[str, ...]] = {
|
|
|
52
53
|
#: pins file by scripts/sync_training_extra.py.
|
|
53
54
|
TRAINING_EXTRA = "training"
|
|
54
55
|
|
|
56
|
+
#: The first interpreter minor whose wheels the training pins lack. The same boundary
|
|
57
|
+
#: as ``NO_WHEELS_FROM`` in scripts/sync_training_extra.py.
|
|
58
|
+
TRAINING_UNSUPPORTED_FROM = (3, 14)
|
|
59
|
+
TRAINING_SUPPORTED_MINORS = "3.11, 3.12 and 3.13"
|
|
60
|
+
|
|
55
61
|
_PIN = re.compile(r"^\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*==\s*([^\s;#]+)")
|
|
56
62
|
#: The ``(/path/to/file.py)`` an ImportError names: this machine's, not the model's.
|
|
57
63
|
_SOURCE_FILE = re.compile(r" \((?:/|[A-Za-z]:\\)[^)]*\)")
|
|
@@ -157,6 +163,13 @@ def refuse_other_versions(sources: Iterable[str]) -> CheckFinding:
|
|
|
157
163
|
Raises :class:`ConversionRefusedError` when a training library they import
|
|
158
164
|
is installed here at another version than training's.
|
|
159
165
|
"""
|
|
166
|
+
if sys.version_info[:2] >= TRAINING_UNSUPPORTED_FROM:
|
|
167
|
+
raise ConversionRefusedError(
|
|
168
|
+
RefusalCause.VERSIONS,
|
|
169
|
+
f"Python {sys.version_info[0]}.{sys.version_info[1]} cannot install "
|
|
170
|
+
f'the training versions (pip install "tracebloc[{TRAINING_EXTRA}]"). '
|
|
171
|
+
f"Use Python {TRAINING_SUPPORTED_MINORS}, then convert again.",
|
|
172
|
+
)
|
|
160
173
|
libraries = imported_libraries(sources)
|
|
161
174
|
clauses = version_mismatches(libraries)
|
|
162
175
|
if clauses:
|
|
@@ -347,10 +347,12 @@ def user_run_inference(
|
|
|
347
347
|
template: A model-zoo pick for this dataset. Pass exactly one of
|
|
348
348
|
``model`` / ``template``.
|
|
349
349
|
name: The run's name; ``"Inference only: <model>"`` when omitted.
|
|
350
|
-
data_type: The dataset's image mode, ``"rgb"`` (the default)
|
|
351
|
-
``"grayscale"
|
|
352
|
-
|
|
353
|
-
|
|
350
|
+
data_type: The dataset's image mode, ``"rgb"`` (the default),
|
|
351
|
+
``"grayscale"`` or, for image classification, ``"multichannel"``,
|
|
352
|
+
as ``data_type()`` sets it on a training plan. A PyTorch image
|
|
353
|
+
model must match it: ``"grayscale"`` for a 1-channel model,
|
|
354
|
+
``"rgb"`` for a 3-channel one, ``"multichannel"`` for any count
|
|
355
|
+
the dataset's images have.
|
|
354
356
|
|
|
355
357
|
Returns:
|
|
356
358
|
The run's experiment key (pass it to ``get_experiment_status``).
|
|
@@ -358,7 +360,7 @@ def user_run_inference(
|
|
|
358
360
|
Raises:
|
|
359
361
|
AuthenticationError: Not logged in.
|
|
360
362
|
ValueError: Neither or both of ``model`` / ``template``, a
|
|
361
|
-
``data_type`` that is not one of ``
|
|
363
|
+
``data_type`` that is not one of ``IMAGE_DATA_TYPES``, or
|
|
362
364
|
the link left the plan ineligible (the errors it printed say what
|
|
363
365
|
to fix); nothing is sent.
|
|
364
366
|
DatasetLinkingError: The model could not be linked to the dataset.
|
|
@@ -8,21 +8,21 @@ import numbers
|
|
|
8
8
|
from tracebloc._deprecation import deprecated_method_alias, discard_removed_kwarg
|
|
9
9
|
from tracebloc.training import subdataset
|
|
10
10
|
from tracebloc.training.subdataset import class_set_error, dataset_error, request_error
|
|
11
|
+
from tracebloc.training.image_channels import image_channel_check
|
|
11
12
|
from tracebloc.utils.general_utils import (
|
|
12
13
|
format_exception,
|
|
13
14
|
get_images_count,
|
|
14
15
|
validate_kwargs,
|
|
15
16
|
get_model_params_count,
|
|
16
|
-
detect_input_channels,
|
|
17
17
|
)
|
|
18
18
|
from tracebloc.utils.constants import (
|
|
19
19
|
IMAGE_DATA_TYPES,
|
|
20
|
+
MULTICHANNEL,
|
|
20
21
|
CONSTANT,
|
|
21
22
|
ADAPTIVE,
|
|
22
23
|
CUSTOM,
|
|
23
24
|
TYPE,
|
|
24
25
|
VALUE,
|
|
25
|
-
PYTORCH_FRAMEWORK,
|
|
26
26
|
TABULAR_CLASSIFICATION,
|
|
27
27
|
TABULAR_REGRESSION,
|
|
28
28
|
TEXT_CLASSIFICATION,
|
|
@@ -34,9 +34,6 @@ from tracebloc.utils.constants import (
|
|
|
34
34
|
EMBEDDINGS,
|
|
35
35
|
TIME_TO_EVENT_PREDICTION,
|
|
36
36
|
IMAGE_CLASSIFICATION,
|
|
37
|
-
OBJECT_DETECTION,
|
|
38
|
-
KEYPOINT_DETECTION,
|
|
39
|
-
SEMANTIC_SEGMENTATION,
|
|
40
37
|
TIME_SERIES_FORECASTING,
|
|
41
38
|
TIME_SERIES_CLASSIFICATION,
|
|
42
39
|
)
|
|
@@ -81,7 +78,7 @@ class LinkModelDataset:
|
|
|
81
78
|
|
|
82
79
|
def __init__(self, **kwargs) -> None:
|
|
83
80
|
discard_removed_kwarg( # before default_dict captures kwargs: never stored
|
|
84
|
-
kwargs, "hf_token", "Hugging Face support is removed
|
|
81
|
+
kwargs, "hf_token", "Hugging Face support is removed"
|
|
85
82
|
)
|
|
86
83
|
self.default_dict = kwargs
|
|
87
84
|
validate_kwargs(
|
|
@@ -128,6 +125,8 @@ class LinkModelDataset:
|
|
|
128
125
|
self.__model_name = kwargs["model_name"]
|
|
129
126
|
self.__model = kwargs["model"]
|
|
130
127
|
self.__data_type = "rgb"
|
|
128
|
+
# A multichannel run's channel count, the model's; None for any other.
|
|
129
|
+
self.__channels = None
|
|
131
130
|
self.__total_dataset_size = kwargs["total_dataset_size"]
|
|
132
131
|
self.__category = kwargs["category"]
|
|
133
132
|
self.__training_dataset_size = kwargs["total_dataset_size"]
|
|
@@ -279,6 +278,7 @@ class LinkModelDataset:
|
|
|
279
278
|
def reset_training_plan(self) -> None:
|
|
280
279
|
self.__callbacks_cfg.reset()
|
|
281
280
|
self.__data_type = "rgb"
|
|
281
|
+
self.__channels = None
|
|
282
282
|
self.__training_dataset_size = self.default_dict["total_dataset_size"]
|
|
283
283
|
self.__training_classes = self.default_dict["class_names"]
|
|
284
284
|
self.__batch_size = self.default_dict["batch_size"]
|
|
@@ -333,61 +333,28 @@ class LinkModelDataset:
|
|
|
333
333
|
return get_model_params_count(framework=self.__framework, model=self.__model)
|
|
334
334
|
|
|
335
335
|
def __validate_image_channels(self):
|
|
336
|
-
"""
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
re-runs this helper) clears it. Returns the error string on mismatch
|
|
352
|
-
else ``None`` (so callers can also surface it inline).
|
|
353
|
-
"""
|
|
354
|
-
if self.__framework != PYTORCH_FRAMEWORK:
|
|
355
|
-
return None
|
|
356
|
-
if self.__category not in (
|
|
357
|
-
IMAGE_CLASSIFICATION,
|
|
358
|
-
OBJECT_DETECTION,
|
|
359
|
-
SEMANTIC_SEGMENTATION,
|
|
360
|
-
KEYPOINT_DETECTION,
|
|
361
|
-
):
|
|
362
|
-
return None
|
|
363
|
-
|
|
364
|
-
# Sentinel default lets us distinguish "no Conv2d -> undetectable"
|
|
365
|
-
# from a genuine 1- or 3-channel model. ``None`` -> treat as no error
|
|
366
|
-
# (we never block on an unknown channel count).
|
|
367
|
-
channels = detect_input_channels(self.__model, default=None)
|
|
368
|
-
|
|
336
|
+
"""Check the model's input channels against ``data_type``
|
|
337
|
+
(``tracebloc.training.image_channels``) and report under this method's
|
|
338
|
+
name, so a later corrective ``data_type()`` clears it. Returns the
|
|
339
|
+
error, or ``None``; sets a multichannel run's ``channels``."""
|
|
340
|
+
self.__channels = None
|
|
341
|
+
attributes = (
|
|
342
|
+
self.__image_attributes if self.__data_type == MULTICHANNEL else None
|
|
343
|
+
)
|
|
344
|
+
check = image_channel_check(
|
|
345
|
+
self.__data_type,
|
|
346
|
+
self.__framework,
|
|
347
|
+
self.__category,
|
|
348
|
+
self.__model,
|
|
349
|
+
attributes,
|
|
350
|
+
)
|
|
369
351
|
error = None
|
|
370
|
-
if
|
|
371
|
-
|
|
372
|
-
error = (
|
|
373
|
-
f"data_type='grayscale' but the model expects {channels} "
|
|
374
|
-
f"input channels. A grayscale dataset feeds 1-channel images "
|
|
375
|
-
f"on the client; use a model with 1 input channel, or set "
|
|
376
|
-
f"data_type('rgb')."
|
|
377
|
-
)
|
|
378
|
-
elif self.__data_type == "rgb" and channels != 3:
|
|
379
|
-
error = (
|
|
380
|
-
f"data_type='rgb' but the model expects {channels} input "
|
|
381
|
-
f"channels. An rgb dataset feeds 3-channel images on the "
|
|
382
|
-
f"client; use a model with 3 input channels, or set "
|
|
383
|
-
f"data_type('grayscale')."
|
|
384
|
-
)
|
|
352
|
+
if check is not None:
|
|
353
|
+
self.__channels, error = check.channels, check.error
|
|
385
354
|
|
|
386
355
|
# Idempotent reporting: drop any prior entry from THIS check before
|
|
387
356
|
# (re)reporting. __print_error appends unconditionally, so without this
|
|
388
|
-
# a repeated call
|
|
389
|
-
# correction) would stack duplicate entries, and a single
|
|
390
|
-
# __remove_error_method would leave a stale one — keeping eligibility
|
|
357
|
+
# a repeated call would stack duplicate entries and keep eligibility
|
|
391
358
|
# false forever.
|
|
392
359
|
self.__error_method = [
|
|
393
360
|
m for m in self.__error_method if m != "__validate_image_channels"
|
|
@@ -437,6 +404,8 @@ class LinkModelDataset:
|
|
|
437
404
|
creates sub dataset of the current dataset of the no of data items per class selected by user
|
|
438
405
|
Please provide number of data items per class, totalling no more
|
|
439
406
|
than the data items the dataset holds. No class labels: training_size(n)
|
|
407
|
+
On patient data a class whose count shows as "<10" (or None) is given
|
|
408
|
+
as "<10": all of its data items.
|
|
440
409
|
example: dataset: {'car': 65, 'person': 42}
|
|
441
410
|
Classes in dataset car, person
|
|
442
411
|
|
|
@@ -459,7 +428,12 @@ class LinkModelDataset:
|
|
|
459
428
|
if impossible := dataset_error(class_names, self.__total_images):
|
|
460
429
|
self.__print_error(impossible)
|
|
461
430
|
return
|
|
431
|
+
if problem := subdataset.whole_class_error(training_dataset, class_names):
|
|
432
|
+
self.__print_error(problem)
|
|
433
|
+
return
|
|
462
434
|
for class_name in class_names:
|
|
435
|
+
if subdataset.is_held(class_names[class_name]):
|
|
436
|
+
continue # asked whole, or missing: whole_class_error, request_error
|
|
463
437
|
num_images = int(class_names[class_name])
|
|
464
438
|
least_data = 5 if num_images > 5 else 1
|
|
465
439
|
if class_name in training_dataset.keys():
|
|
@@ -496,7 +470,8 @@ class LinkModelDataset:
|
|
|
496
470
|
self.__print_error(problem)
|
|
497
471
|
return
|
|
498
472
|
self.__training_classes = training_dataset
|
|
499
|
-
|
|
473
|
+
held = subdataset.any_held(training_dataset) # a sum no number states
|
|
474
|
+
self.__training_dataset_size = None if held else get_images_count(training_dataset)
|
|
500
475
|
# recalculate the validation split
|
|
501
476
|
data = {
|
|
502
477
|
"edges_involved": json.dumps(list(self.__data_per_edge.keys())),
|
|
@@ -670,7 +645,10 @@ class LinkModelDataset:
|
|
|
670
645
|
def data_type(self, data_type: str) -> None:
|
|
671
646
|
"""
|
|
672
647
|
Set image type to be used for training
|
|
673
|
-
parameters: one of IMAGE_DATA_TYPES, 'rgb'
|
|
648
|
+
parameters: one of IMAGE_DATA_TYPES, 'rgb', 'grayscale' (not 'gray')
|
|
649
|
+
or, for image classification, 'multichannel': every image's
|
|
650
|
+
channels read as stored, as many as the model's first Conv2d takes
|
|
651
|
+
(1 to 64)
|
|
674
652
|
example: trainingObject.data_type('rgb')
|
|
675
653
|
default: rgb
|
|
676
654
|
"""
|
|
@@ -678,7 +656,7 @@ class LinkModelDataset:
|
|
|
678
656
|
try:
|
|
679
657
|
if type(data_type) is str:
|
|
680
658
|
allowed_types.index(data_type.lower())
|
|
681
|
-
previous = self.__data_type
|
|
659
|
+
previous = (self.__data_type, self.__channels)
|
|
682
660
|
self.__data_type = data_type.lower()
|
|
683
661
|
# PyTorch (and other frameworks): the model's input channels
|
|
684
662
|
# are fixed, so the chosen data_type must match them.
|
|
@@ -688,8 +666,14 @@ class LinkModelDataset:
|
|
|
688
666
|
if channel_error:
|
|
689
667
|
# Roll back so __data_type stays consistent with the
|
|
690
668
|
# model the user actually has.
|
|
691
|
-
self.__data_type = previous
|
|
669
|
+
self.__data_type, self.__channels = previous
|
|
692
670
|
return
|
|
671
|
+
dropped = self.__aug.drop_colour_settings(self.__data_type)
|
|
672
|
+
if dropped:
|
|
673
|
+
self.__warn_unsupported(
|
|
674
|
+
f"dataType:{', '.join(dropped)} cleared: data_type "
|
|
675
|
+
f"{self.__data_type!r} does not take it\n"
|
|
676
|
+
)
|
|
693
677
|
self.__remove_error_method()
|
|
694
678
|
else:
|
|
695
679
|
error_msg = f"dataType:enter image type as string\n"
|
|
@@ -23,6 +23,7 @@ from __future__ import annotations
|
|
|
23
23
|
from typing import Any, Callable
|
|
24
24
|
|
|
25
25
|
from tracebloc.utils.constants import (
|
|
26
|
+
MULTICHANNEL,
|
|
26
27
|
LIFELINES_FRAMEWORK,
|
|
27
28
|
PYTORCH_FRAMEWORK,
|
|
28
29
|
SCIKIT_SURVIVAL_FRAMEWORK,
|
|
@@ -170,6 +171,12 @@ class AugmentationConfig:
|
|
|
170
171
|
def brightness_range(self, brightness_range) -> None:
|
|
171
172
|
if self._framework in _NON_IMAGE_FRAMEWORKS:
|
|
172
173
|
self._on_invalid(_image_aug_unsupported("brightness_range", self._framework))
|
|
174
|
+
elif self._get_data_type() == MULTICHANNEL:
|
|
175
|
+
# The engine's ColorJitter reads 1 or 3 colour channels only.
|
|
176
|
+
self._on_invalid(
|
|
177
|
+
"brightness_range:You can not set brightness_range if image type "
|
|
178
|
+
"is multichannel\n"
|
|
179
|
+
)
|
|
173
180
|
elif type(brightness_range) == float:
|
|
174
181
|
self._brightness_range = str(brightness_range)
|
|
175
182
|
self._on_valid()
|
|
@@ -196,6 +203,19 @@ class AugmentationConfig:
|
|
|
196
203
|
else:
|
|
197
204
|
self._on_invalid("zoom_range:Invalid input type given for zoom_range\n")
|
|
198
205
|
|
|
206
|
+
def drop_colour_settings(self, data_type: str) -> list[str]:
|
|
207
|
+
"""Clear the colour augmentations ``data_type`` cannot take, set before
|
|
208
|
+
a switch to it, and return their names: brightness reads 1 or 3
|
|
209
|
+
channels (not multichannel), a channel shift rgb's three."""
|
|
210
|
+
dropped = []
|
|
211
|
+
if data_type == MULTICHANNEL and self._brightness_range != "None":
|
|
212
|
+
self._brightness_range = "None"
|
|
213
|
+
dropped.append("brightness_range")
|
|
214
|
+
if data_type != "rgb" and self._channel_shift_range:
|
|
215
|
+
self._channel_shift_range = 0.0
|
|
216
|
+
dropped.append("channel_shift_range")
|
|
217
|
+
return dropped
|
|
218
|
+
|
|
199
219
|
def channel_shift_range(self, channel_shift_range: float) -> None:
|
|
200
220
|
if self._framework in _NON_IMAGE_FRAMEWORKS:
|
|
201
221
|
# A channel shift is a pure image augmentation with no meaning for a
|
|
@@ -11,12 +11,15 @@ from dataclasses import dataclass
|
|
|
11
11
|
from typing import Any
|
|
12
12
|
|
|
13
13
|
from tracebloc.training.memory_estimate import per_run_limit_bytes
|
|
14
|
+
from tracebloc.utils.constants import MAX_IMAGE_CHANNELS
|
|
14
15
|
|
|
15
16
|
#: The plan fields the backend's experiment create reads a model's own image
|
|
16
|
-
#: normalisation from:
|
|
17
|
+
#: normalisation from: one finite number per channel, 1 to MAX_IMAGE_CHANNELS
|
|
18
|
+
#: each, std above 0, sent together.
|
|
17
19
|
NORMALISATION_FIELDS = ("normalization_mean", "normalization_std")
|
|
18
20
|
#: The ``data_type`` whose images have three channels.
|
|
19
21
|
RGB = "rgb"
|
|
22
|
+
GRAYSCALE = "grayscale"
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
@dataclass(frozen=True)
|
|
@@ -28,14 +31,22 @@ class Normalisation:
|
|
|
28
31
|
detail: str
|
|
29
32
|
|
|
30
33
|
def plan_fields(self, data_type: Any) -> dict[str, str]:
|
|
31
|
-
"""The create payload's fields, JSON lists as a form post carries them
|
|
34
|
+
"""The create payload's fields, JSON lists as a form post carries them,
|
|
35
|
+
or none for a pair the backend refuses for ``data_type``.
|
|
32
36
|
|
|
33
37
|
A one-value pair is repeated per channel for an rgb run, as a
|
|
34
|
-
one-value ``Normalize`` broadcasts over three channels.
|
|
38
|
+
one-value ``Normalize`` broadcasts over three channels. rgb takes 3
|
|
39
|
+
values and grayscale 1 or 3; a multichannel run's count is checked
|
|
40
|
+
against its ``channels`` by the backend.
|
|
35
41
|
"""
|
|
36
42
|
mean, std = self.mean, self.std
|
|
37
|
-
|
|
43
|
+
kind = str(data_type or RGB).strip().lower()
|
|
44
|
+
if kind == RGB and len(mean) == 1:
|
|
38
45
|
mean, std = mean * 3, std * 3
|
|
46
|
+
if (kind == RGB and len(mean) != 3) or (
|
|
47
|
+
kind == GRAYSCALE and len(mean) not in (1, 3)
|
|
48
|
+
):
|
|
49
|
+
return {}
|
|
39
50
|
return {
|
|
40
51
|
"normalization_mean": json.dumps(list(mean)),
|
|
41
52
|
"normalization_std": json.dumps(list(std)),
|
|
@@ -43,7 +54,10 @@ class Normalisation:
|
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
def _channels(value: Any) -> tuple[float, ...] | None:
|
|
46
|
-
if
|
|
57
|
+
if (
|
|
58
|
+
not isinstance(value, (list, tuple))
|
|
59
|
+
or not 1 <= len(value) <= MAX_IMAGE_CHANNELS
|
|
60
|
+
):
|
|
47
61
|
return None
|
|
48
62
|
numbers = []
|
|
49
63
|
for item in value:
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Does the model's input channel count fit the plan's image ``data_type``?
|
|
2
|
+
|
|
3
|
+
The PyTorch client loads a grayscale dataset as 1-channel images and an rgb one
|
|
4
|
+
as 3-channel images. A model whose first Conv2d expects another count validates
|
|
5
|
+
fine at upload but crashes on the client, so the link checks it. A multichannel
|
|
6
|
+
run reads every image's channels as stored, so the model's count is the run's
|
|
7
|
+
``channels``, 1 to ``MAX_IMAGE_CHANNELS``, and the dataset's images must have it.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any, Optional
|
|
14
|
+
|
|
15
|
+
from tracebloc.utils.constants import (
|
|
16
|
+
IMAGE_CLASSIFICATION,
|
|
17
|
+
KEYPOINT_DETECTION,
|
|
18
|
+
MAX_IMAGE_CHANNELS,
|
|
19
|
+
MULTICHANNEL,
|
|
20
|
+
OBJECT_DETECTION,
|
|
21
|
+
PYTORCH_FRAMEWORK,
|
|
22
|
+
SEMANTIC_SEGMENTATION,
|
|
23
|
+
)
|
|
24
|
+
from tracebloc.utils.general_utils import detect_input_channels
|
|
25
|
+
|
|
26
|
+
_IMAGE_CATEGORIES = (
|
|
27
|
+
IMAGE_CLASSIFICATION,
|
|
28
|
+
OBJECT_DETECTION,
|
|
29
|
+
SEMANTIC_SEGMENTATION,
|
|
30
|
+
KEYPOINT_DETECTION,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True)
|
|
35
|
+
class ChannelCheck:
|
|
36
|
+
"""``error`` to report, or ``None``; ``channels`` a multichannel run's count."""
|
|
37
|
+
|
|
38
|
+
error: Optional[str]
|
|
39
|
+
channels: Optional[int] = None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _multichannel(framework: Any, category: Any, model: Any, attributes: Any):
|
|
43
|
+
channels = (
|
|
44
|
+
detect_input_channels(model, default=None)
|
|
45
|
+
if framework == PYTORCH_FRAMEWORK
|
|
46
|
+
else None
|
|
47
|
+
)
|
|
48
|
+
dataset_channels = (attributes or {}).get("channels")
|
|
49
|
+
if category != IMAGE_CLASSIFICATION:
|
|
50
|
+
return ChannelCheck(
|
|
51
|
+
f"data_type='multichannel' is read by image classification only, "
|
|
52
|
+
f"not {category}."
|
|
53
|
+
)
|
|
54
|
+
if channels is None:
|
|
55
|
+
return ChannelCheck(
|
|
56
|
+
"data_type='multichannel' takes its channel count from the model's "
|
|
57
|
+
"first convolution, and this model has none to read; use a PyTorch "
|
|
58
|
+
"model whose first layer is a Conv2d."
|
|
59
|
+
)
|
|
60
|
+
if not 1 <= channels <= MAX_IMAGE_CHANNELS:
|
|
61
|
+
return ChannelCheck(
|
|
62
|
+
f"data_type='multichannel' reads 1 to {MAX_IMAGE_CHANNELS} channels, "
|
|
63
|
+
f"and the model expects {channels}."
|
|
64
|
+
)
|
|
65
|
+
if isinstance(dataset_channels, int) and dataset_channels != channels:
|
|
66
|
+
return ChannelCheck(
|
|
67
|
+
f"data_type='multichannel' but the model expects {channels} input "
|
|
68
|
+
f"channels and the dataset's images have {dataset_channels}; use a "
|
|
69
|
+
f"model with {dataset_channels} input channels."
|
|
70
|
+
)
|
|
71
|
+
return ChannelCheck(None, channels)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _recovery(channels: int, category: Any, colour: str) -> str:
|
|
75
|
+
"""The data_type that would read a ``channels``-channel model."""
|
|
76
|
+
if channels not in (1, 3) and category == IMAGE_CLASSIFICATION:
|
|
77
|
+
if 1 <= channels <= MAX_IMAGE_CHANNELS:
|
|
78
|
+
return "or set data_type('multichannel')"
|
|
79
|
+
return f"or set data_type('{colour}')"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def image_channel_check(
|
|
83
|
+
data_type: Any, framework: Any, category: Any, model: Any, attributes: Any = None
|
|
84
|
+
) -> Optional[ChannelCheck]:
|
|
85
|
+
"""The check's verdict, or ``None`` where it does not apply: a colour run
|
|
86
|
+
off PyTorch or off the image tasks. A colour model whose count cannot be
|
|
87
|
+
read (no Conv2d) passes: the link never blocks on an unknown."""
|
|
88
|
+
if data_type == MULTICHANNEL:
|
|
89
|
+
return _multichannel(framework, category, model, attributes)
|
|
90
|
+
if framework != PYTORCH_FRAMEWORK or category not in _IMAGE_CATEGORIES:
|
|
91
|
+
return None
|
|
92
|
+
channels = detect_input_channels(model, default=None)
|
|
93
|
+
if channels is None:
|
|
94
|
+
return ChannelCheck(None)
|
|
95
|
+
if data_type == "grayscale" and channels != 1:
|
|
96
|
+
return ChannelCheck(
|
|
97
|
+
f"data_type='grayscale' but the model expects {channels} input "
|
|
98
|
+
f"channels. A grayscale dataset feeds 1-channel images on the client; "
|
|
99
|
+
f"use a model with 1 input channel, {_recovery(channels, category, 'rgb')}."
|
|
100
|
+
)
|
|
101
|
+
if data_type == "rgb" and channels != 3:
|
|
102
|
+
return ChannelCheck(
|
|
103
|
+
f"data_type='rgb' but the model expects {channels} input channels. An "
|
|
104
|
+
f"rgb dataset feeds 3-channel images on the client; use a model with "
|
|
105
|
+
f"3 input channels, {_recovery(channels, category, 'grayscale')}."
|
|
106
|
+
)
|
|
107
|
+
return ChannelCheck(None)
|
|
@@ -37,6 +37,7 @@ from tracebloc.utils.constants import (
|
|
|
37
37
|
TYPE,
|
|
38
38
|
VALUE,
|
|
39
39
|
)
|
|
40
|
+
from tracebloc.training.subdataset import is_held
|
|
40
41
|
from tracebloc.utils.general_utils import format_exception
|
|
41
42
|
|
|
42
43
|
|
|
@@ -143,7 +144,7 @@ class TrainingPlan:
|
|
|
143
144
|
self,
|
|
144
145
|
framework: str,
|
|
145
146
|
num_classes: int,
|
|
146
|
-
data_per_edge: Mapping[str, int],
|
|
147
|
+
data_per_edge: Mapping[str, int | str | None],
|
|
147
148
|
batch_size: int,
|
|
148
149
|
*,
|
|
149
150
|
on_valid: Callable[[], None],
|
|
@@ -294,9 +295,16 @@ class TrainingPlan:
|
|
|
294
295
|
self._on_invalid("objective:Please enter a string in objective\n")
|
|
295
296
|
|
|
296
297
|
def _minimum_validation_split(self) -> float:
|
|
297
|
-
"""Lower bound ``validation_split`` accepts: one row per class on the smallest edge.
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
"""Lower bound ``validation_split`` accepts: one row per class on the smallest edge.
|
|
299
|
+
|
|
300
|
+
An edge whose count is held (``is_held``) or empty sets no bound here:
|
|
301
|
+
the engine counts the held rows, and an empty edge has no row to bound.
|
|
302
|
+
"""
|
|
303
|
+
counts = {e: n for e, n in self._data_per_edge.items() if not is_held(n) and int(n) > 0}
|
|
304
|
+
if self._data_per_edge and not counts:
|
|
305
|
+
return 0.1
|
|
306
|
+
edge_min = min(counts, key=counts.get)
|
|
307
|
+
images = int(counts[edge_min])
|
|
300
308
|
floor = round(self._num_classes / images, 2)
|
|
301
309
|
return 0.1 if floor == 0 else min(floor, 0.5)
|
|
302
310
|
|