Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.1
19 changes: 18 additions & 1 deletion application/backend/app/api/schemas/training_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def _model_to_parameter_group(
parameters.append(nested_group)
else:
# Resolve allowed_values from another field or StrEnum annotation
allowed_values = cls._resolve_allowed_values(model, child_field_info)
allowed_values = cls._resolve_allowed_values(default_model or model, child_field_info)

# Get the default value from the default model, falling back to field_info.default
if default_model is not None:
Expand Down Expand Up @@ -1235,6 +1235,23 @@ def from_training_configuration(
"max_value": 1.0,
"allowed_values": None,
},
{
"type": "parameter",
"key": "min_object_ratio_thr",
"name": "Object visibility threshold in tile",
"description": (
"Minimum fraction of an annotation's bounding box or polygon "
"area that must be visible in a tile. Annotations below this "
"threshold are excluded from the tile. A value of 0 keeps "
"every intersecting annotation."
),
"value": 0.5,
"default_value": 0.5,
"value_type": "float",
"min_value": 0.0,
"max_value": 1.0,
"allowed_values": None,
},
],
},
],
Expand Down
28 changes: 11 additions & 17 deletions application/backend/app/execution/common/geti_config_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def update_tiling(tiling_dict: dict | None, config: dict) -> None:
"""Update tiling parameters in the config.

Args:
tiling_dict: Dict with keys: enable, enable_adaptive_tiling, tile_size, tile_overlap.
tiling_dict: Tiling settings, including the object visibility threshold in tile.
config: The full getitune config dictionary.
"""
if tiling_dict is None:
Expand All @@ -425,6 +425,8 @@ def update_tiling(tiling_dict: dict | None, config: dict) -> None:
tiling_dict["tile_size"],
)
tile_config["overlap"] = tiling_dict["tile_overlap"]
if "min_object_ratio_thr" in tiling_dict:
tile_config["min_object_ratio_thr"] = tiling_dict["min_object_ratio_thr"]


class HyperparametersUpdater:
Expand Down Expand Up @@ -493,11 +495,15 @@ def _update_batch_size(param_value: int | None, config: dict) -> None:

@staticmethod
def _update_num_workers(param_value: int | None, config: dict) -> None:
"""Update the number of dataloader workers for all subsets."""
"""Update the number of dataloader workers for train and val subsets.

The test subset keeps the recipe value: tiled test loaders are memory-heavy
and the recipe sets their worker count explicitly.
"""
if param_value is None:
logger.info("Number of workers is not provided, skipping update.")
return
for subset in ("train_subset", "val_subset", "test_subset"):
for subset in ("train_subset", "val_subset"):
config["data"][subset]["num_workers"] = param_value

@staticmethod
Expand Down Expand Up @@ -529,19 +535,6 @@ def _update_early_stopping(early_stopping_cfg: dict | None, config: dict) -> Non
if patience is not None:
config["callbacks"][idx]["init_args"]["patience"] = patience

@staticmethod
def update_tiling(tiling_dict: dict | None, config: dict) -> None:
"""Update tiling parameters in the config."""
if tiling_dict is None:
logger.info("Tiling parameters are not provided, skipping update.")
return

config["data"]["tile_config"]["enable_tiler"] = tiling_dict["enable"]
if tiling_dict["enable"]:
config["data"]["tile_config"]["enable_adaptive_tiling"] = tiling_dict["enable_adaptive_tiling"]
config["data"]["tile_config"]["tile_size"] = (tiling_dict["tile_size"], tiling_dict["tile_size"])
config["data"]["tile_config"]["overlap"] = tiling_dict["tile_overlap"]

@staticmethod
def _update_input_size(size_value: tuple[int, int] | None, config: dict) -> None:
"""Update input size in the config.
Expand Down Expand Up @@ -753,7 +746,8 @@ def _convert_huggingface( # noqa: C901, PLR0912
config_dict["data"][subset_name]["batch_size"] = value

if (num_workers := training_parameters.get("num_workers")) is not None:
for subset_name in ("train_subset", "val_subset", "test_subset"):
# The test subset keeps the recipe worker count (see HyperparametersUpdater._update_num_workers).
for subset_name in ("train_subset", "val_subset"):
config_dict["data"][subset_name]["num_workers"] = num_workers

early_stopping = training_parameters.get("early_stopping")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def prepare_model(
)

@step("Train Model", 80)
def train_model( # noqa: PLR0915, C901 - training orchestration is intentionally centralized here
def train_model( # noqa: PLR0912, PLR0915, C901 - training orchestration is intentionally centralized here
self,
training_config: dict,
dataset_info: DatasetInfo,
Expand Down Expand Up @@ -492,6 +492,8 @@ def train_model( # noqa: PLR0915, C901 - training orchestration is intentionall
"work_dir": self._data_dir / f"getitune-workspace-{model_id}",
"device": getitune_device_type,
}
if is_ultralytics and weights_path is not None:
engine_kwargs["weights_dir"] = weights_path.parent
# timm weights (`weights_path=None`) are loaded in the library
if weights_path is not None:
# Route weight loading through checkpoint for Ultralytics and for resume flows.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from pydantic import BaseModel, Field, model_validator
from pydantic import BaseModel, ConfigDict, Field, model_validator


class BaseAugmentationParameter(BaseModel):
Expand Down Expand Up @@ -331,6 +331,10 @@ class GaussianNoise(BaseAugmentationParameter):


class Tiling(BaseAugmentationParameter):
# ``TrainingConfiguration.apply_updates`` assigns values with ``setattr``, so validate on assignment to
# reject out-of-range updates such as ``min_object_ratio_thr``.
model_config = ConfigDict(validate_assignment=True)

enable_adaptive_tiling: bool = Field(
default=False, title="Adaptive tiling", description="Whether to use adaptive tiling based on image content"
)
Expand All @@ -353,6 +357,17 @@ class Tiling(BaseAugmentationParameter):
title="Tile overlap",
description="Overlap between adjacent tiles as a fraction of tile size",
)
min_object_ratio_thr: float = Field(
default=0.5,
ge=0.0,
le=1.0,
title="Object visibility threshold in tile",
description=(
"Minimum fraction of an annotation's bounding box or polygon area that must be visible in a tile. "
"Annotations below this threshold are excluded from the tile. "
"A value of 0 keeps every intersecting annotation."
),
)


class Mosaic(BaseAugmentationParameter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ class AlgoLevelTrainingParameters(BaseModel):
num_workers: int = Field(
ge=0,
le=64,
default=4,
default=2,
title="Number of workers",
description=(
"Number of subprocesses used for data loading. 0 means that the data will be loaded in the main "
"process. More workers can speed up data loading and augmentation, at the cost of higher CPU and "
"memory usage."
"Number of subprocesses used for training and validation data loading. 0 loads data in the main process. "
"More workers can speed up data loading and augmentation, at the cost of higher CPU and memory usage. "
"Testing uses the model recipe's worker count."
),
)
early_stopping: EarlyStopping = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,21 @@ def get_by_model_architecture(self, project_id: UUID, model_architecture_id: str
else:
task_level_parameters = TaskLevelParameters.model_validate(task_level_config_db.configuration_data)

model_manifest = ModelManifestService.get_model_manifest_by_id(model_manifest_id=model_architecture_id)

algo_level_config_db = training_config_repo.get_algo_level_configuration(
project_id=str(project_id), model_architecture_id=model_architecture_id
)
if algo_level_config_db is None:
algo_level_parameters = deepcopy(default_config.algo_level_parameters)
else:
algo_level_parameters = AlgoLevelParameters.model_validate(algo_level_config_db.configuration_data)
configuration_data = deepcopy(algo_level_config_db.configuration_data)
# allowed_values_input_size is a manifest-derived constraint, not user data: always resync it to the
# current manifest instead of trusting a stale, previously-persisted snapshot.
configuration_data.setdefault("training", {})["allowed_values_input_size"] = (
model_manifest.hyperparameters.training.allowed_values_input_size
)
algo_level_parameters = AlgoLevelParameters.model_validate(configuration_data)

training_configuration = TrainingConfiguration(
task_level_parameters=task_level_parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hyperparameters:
enable_adaptive_tiling: true
tile_size: 400
tile_overlap: 0.2
min_object_ratio_thr: 0.5
iou_random_crop:
enable: true
probability: 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ hyperparameters:
enable: true
epochs: 30
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ hyperparameters:
enable: true
epochs: 30
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ hyperparameters:
enable: true
epochs: 30
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ hyperparameters:
enable: true
epochs: 30
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ hyperparameters:
enable: true
epochs: 30
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ hyperparameters:
enable: true
epochs: 30
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ hyperparameters:
enable: true
max_grad_norm: 0.1
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ hyperparameters:
enable: true
max_grad_norm: 0.1
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ hyperparameters:
enable: true
max_grad_norm: 0.1
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ hyperparameters:
enable: true
max_grad_norm: 0.1
allowed_values_input_size:
- 384
- 512
- 640
- 800
- 960
- 1024
- 1280
input_size_width: 640
input_size_height: 640
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ hyperparameters:
- 704
- 768
- 896
- 1024
- 1152
- 1280
input_size_width: 704
input_size_height: 704
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ hyperparameters:
- 704
- 768
- 896
- 1024
- 1152
- 1280
input_size_width: 576
input_size_height: 576
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ hyperparameters:
- 704
- 768
- 896
- 1024
- 1152
- 1280
input_size_width: 384
input_size_height: 384
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ hyperparameters:
- 704
- 768
- 896
- 1024
- 1152
- 1280
input_size_width: 512
input_size_height: 512
dataset_preparation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ hyperparameters:
enable_adaptive_tiling: true
tile_size: 400
tile_overlap: 0.2
min_object_ratio_thr: 0.5
random_horizontal_flip:
enable: true
probability: 0.5
Expand Down
Loading
Loading