Skip to content

Commit 0078967

Browse files
author
Songki Choi
authored
Set "Auto" as default input size mode (#2515)
* Refine input size adaptation * Enable auto input size to integration tests * Set 'Auto' as default mode of input size config * Fix rotated detection config * Update README.md * Update CHANGELOG.md --------- Signed-off-by: Songki Choi <[email protected]>
1 parent e741ad2 commit 0078967

File tree

14 files changed

+126
-45
lines changed

14 files changed

+126
-45
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file.
2525
- Adapt timeout value of initialization for distributed training (<https://github.com/openvinotoolkit/training_extensions/pull/2422>)
2626
- Optimize data loading by merging load & resize operations w/ caching support for cls/det/iseg/sseg (<https://github.com/openvinotoolkit/training_extensions/pull/2438>, <https://github.com/openvinotoolkit/training_extensions/pull/2453>, <https://github.com/openvinotoolkit/training_extensions/pull/2460>)
2727
- Support torch==2.0.1 (<https://github.com/openvinotoolkit/training_extensions/pull/2465>)
28+
- Set "Auto" as default input size mode (<https://github.com/openvinotoolkit/training_extensions/pull/2515>)
2829

2930
### Bug fixes
3031

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@
3333
## Introduction
3434

3535
OpenVINO™ Training Extensions is a low-code transfer learning framework for Computer Vision.
36-
The CLI commands of the framework allows users to train, infer, optimize and deploy models easily and quickly even with low expertise in the deep learning field. OpenVINO™ Training Extensions offers diverse combinations of model architectures, learning methods, and task types based on [PyTorch](https://pytorch.org) and [OpenVINO™
37-
toolkit](https://software.intel.com/en-us/openvino-toolkit).
36+
The CLI commands of the framework allows users to train, infer, optimize and deploy models easily and quickly even with low expertise in the deep learning field.
37+
OpenVINO™ Training Extensions offers diverse combinations of model architectures, learning methods, and task types based on [PyTorch](https://pytorch.org) and [OpenVINO™ toolkit](https://software.intel.com/en-us/openvino-toolkit).
3838

3939
OpenVINO™ Training Extensions provides a "model template" for every supported task type, which consolidates necessary information to build a model.
4040
Model templates are validated on various datasets and serve one-stop shop for obtaining the best models in general.
41-
If you are an experienced user, you can configure your own model based on [torchvision](https://pytorch.org/vision/stable/index.html), [pytorchcv](https://github.com/osmr/imgclsmob), [mmcv](https://github.com/open-mmlab/mmcv) and [OpenVINO Model Zoo (OMZ)](https://github.com/openvinotoolkit/open_model_zoo).
41+
If you are an experienced user, you can configure your own model based on [torchvision](https://pytorch.org/vision/stable/index.html), [mmcv](https://github.com/open-mmlab/mmcv), [timm](https://github.com/huggingface/pytorch-image-models) and [OpenVINO Model Zoo (OMZ)](https://github.com/openvinotoolkit/open_model_zoo).
4242

43-
Furthermore, OpenVINO™ Training Extensions provides automatic configuration of task types and hyperparameters.
44-
The framework will identify the most suitable model template based on your dataset, and choose the best hyperparameter configuration. The development team is continuously extending functionalities to make training as simple as possible so that single CLI command can obtain accurate, efficient and robust models ready to be integrated into your project.
43+
Furthermore, OpenVINO™ Training Extensions provides automatic configuration for ease of use.
44+
The framework will analyze your dataset and identify the most suitable model and figure out the best input size setting and other hyper-parameters.
45+
The development team is continuously extending this [Auto-configuration](https://openvinotoolkit.github.io/training_extensions/latest/guide/explanation/additional_features/auto_configuration.html) functionalities to make training as simple as possible so that single CLI command can obtain accurate, efficient and robust models ready to be integrated into your project.
4546

4647
### Key Features
4748

@@ -60,13 +61,13 @@ OpenVINO™ Training Extensions supports the [following learning methods](https:
6061
- **Semi-supervised learning**
6162
- **Self-supervised learning**
6263

63-
OpenVINO™ Training Extensions will provide the following features in coming releases:
64+
OpenVINO™ Training Extensions provides the following usability features:
6465

66+
- [Auto-configuration](https://openvinotoolkit.github.io/training_extensions/latest/guide/explanation/additional_features/auto_configuration.html). OpenVINO™ Training Extensions analyzes provided dataset and selects the proper task and model with appropriate input size to provide the best accuracy/speed trade-off. It will also make a random auto-split of your dataset if there is no validation set provided.
67+
- [Datumaro](https://openvinotoolkit.github.io/datumaro/stable/index.html) data frontend: OpenVINO™ Training Extensions supports the most common academic field dataset formats for each task. We are constantly working to extend supported formats to give more freedom of datasets format choice.
6568
- **Distributed training** to accelerate the training process when you have multiple GPUs
66-
- **Half-precision training** to save GPUs memory and use larger batch sizes
69+
- **Mixed-precision training** to save GPUs memory and use larger batch sizes
6770
- Integrated, efficient [hyper-parameter optimization module (HPO)](https://openvinotoolkit.github.io/training_extensions/latest/guide/explanation/additional_features/hpo.html). Through dataset proxy and built-in hyper-parameter optimizer, you can get much faster hyper-parameter optimization compared to other off-the-shelf tools. The hyperparameter optimization is dynamically scheduled based on your resource budget.
68-
- OpenVINO™ Training Extensions uses [Datumaro](https://openvinotoolkit.github.io/datumaro/stable/index.html) as the backend to hadle datasets. Thanks to that, OpenVINO™ Training Extensions supports the most common academic field dataset formats for each task. We constantly working to extend supported formats to give more freedom of datasets format choice.
69-
- [Auto-configuration functionality](https://openvinotoolkit.github.io/training_extensions/latest/guide/explanation/additional_features/auto_configuration.html). OpenVINO™ Training Extensions analyzes provided dataset and selects the proper task and model template to provide the best accuracy/speed trade-off. It will also make a random auto-split of your dataset if there is no validation set provided.
7071

7172
---
7273

src/otx/algorithms/classification/configs/configuration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ learning_parameters:
277277
warning: null
278278
input_size:
279279
affects_outcome_of: INFERENCE
280-
default_value: Default
280+
default_value: Auto
281281
description:
282282
The input size of the given model could be configured to one of the predefined resolutions.
283283
Reduced training and inference time could be expected by using smaller input size.
284-
Defaults to per-model default resolution.
284+
Defaults to Auto, in which input size is automatically determined based on dataset statistics.
285285
editable: true
286286
enum_name: InputSizePreset
287287
header: Configure model input size.

src/otx/algorithms/common/adapters/mmcv/utils/config_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ class InputSizeManager:
641641

642642
MIN_RECOGNIZABLE_OBJECT_SIZE = 32 # Minimum object size recognizable by NNs: typically 16 ~ 32
643643
# meaning NxN input pixels being downscaled to 1x1 on feature map
644+
MIN_DETECTION_INPUT_SIZE = 256 # Minimum input size for object detection
644645

645646
def __init__(
646647
self,
@@ -960,6 +961,12 @@ def adapt_input_size_to_dataset(
960961
if min_object_size is not None and min_object_size > 0:
961962
image_size = round(image_size * self.MIN_RECOGNIZABLE_OBJECT_SIZE / min_object_size)
962963
logger.info(f"-> Based on typical small object size {min_object_size}: {image_size}")
964+
if image_size > max_image_size:
965+
image_size = max_image_size
966+
logger.info(f"-> Restrict to max image size: {image_size}")
967+
if image_size < self.MIN_DETECTION_INPUT_SIZE:
968+
image_size = self.MIN_DETECTION_INPUT_SIZE
969+
logger.info(f"-> Based on minimum object detection input size: {image_size}")
963970

964971
input_size = (round(image_size), round(image_size))
965972

src/otx/algorithms/detection/configs/detection/configuration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ learning_parameters:
245245
warning: null
246246
input_size:
247247
affects_outcome_of: INFERENCE
248-
default_value: Default
248+
default_value: Auto
249249
description:
250250
The input size of the given model could be configured to one of the predefined resolutions.
251251
Reduced training and inference time could be expected by using smaller input size.
252-
Defaults to per-model default resolution.
252+
Defaults to Auto, in which input size is automatically determined based on dataset statistics.
253253
editable: true
254254
enum_name: InputSizePreset
255255
header: Configure model input size.

src/otx/algorithms/detection/configs/instance_segmentation/configuration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ learning_parameters:
245245
warning: null
246246
input_size:
247247
affects_outcome_of: INFERENCE
248-
default_value: Default
248+
default_value: Auto
249249
description:
250250
The input size of the given model could be configured to one of the predefined resolutions.
251251
Reduced training and inference time could be expected by using smaller input size.
252-
Defaults to per-model default resolution.
252+
Defaults to Auto, in which input size is automatically determined based on dataset statistics.
253253
editable: true
254254
enum_name: InputSizePreset
255255
header: Configure model input size.

src/otx/algorithms/detection/configs/rotated_detection/configuration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ learning_parameters:
245245
warning: null
246246
input_size:
247247
affects_outcome_of: INFERENCE
248-
default_value: Default
248+
default_value: Auto
249249
description:
250250
The input size of the given model could be configured to one of the predefined resolutions.
251251
Reduced training and inference time could be expected by using smaller input size.
252-
Defaults to per-model default resolution.
252+
Defaults to Auto, in which input size is automatically determined based on dataset statistics.
253253
editable: true
254254
enum_name: InputSizePreset
255255
header: Configure model input size.

src/otx/algorithms/segmentation/configs/configuration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ learning_parameters:
232232
warning: null
233233
input_size:
234234
affects_outcome_of: INFERENCE
235-
default_value: Default
235+
default_value: Auto
236236
description:
237237
The input size of the given model could be configured to one of the predefined resolutions.
238238
Reduced training and inference time could be expected by using smaller input size.
239-
Defaults to per-model default resolution.
239+
Defaults to Auto, in which input size is automatically determined based on dataset statistics.
240240
editable: true
241241
enum_name: InputSizePreset
242242
header: Configure model input size.

tests/integration/cli/classification/test_classification.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@
5252
args_selfsl = {
5353
"--train-data-roots": "tests/assets/classification_dataset",
5454
"--train-type": "Selfsupervised",
55-
"train_params": ["params", "--learning_parameters.num_iters", "1", "--learning_parameters.batch_size", "4"],
55+
"train_params": [
56+
"params",
57+
"--learning_parameters.num_iters",
58+
"1",
59+
"--learning_parameters.batch_size",
60+
"4",
61+
],
5662
}
5763

5864
# Training params for resume, num_iters*2

tests/integration/cli/detection/test_detection.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636
"--val-data-roots": "tests/assets/car_tree_bug",
3737
"--test-data-roots": "tests/assets/car_tree_bug",
3838
"--input": "tests/assets/car_tree_bug/images/train",
39-
"train_params": ["params", "--learning_parameters.num_iters", "1", "--learning_parameters.batch_size", "4"],
39+
"train_params": [
40+
"params",
41+
"--learning_parameters.num_iters",
42+
"1",
43+
"--learning_parameters.batch_size",
44+
"4",
45+
],
4046
}
4147

4248
args_semisl = {
@@ -45,7 +51,13 @@
4551
"--test-data-roots": "tests/assets/car_tree_bug",
4652
"--unlabeled-data-roots": "tests/assets/car_tree_bug",
4753
"--input": "tests/assets/car_tree_bug/images/train",
48-
"train_params": ["params", "--learning_parameters.num_iters", "1", "--learning_parameters.batch_size", "4"],
54+
"train_params": [
55+
"params",
56+
"--learning_parameters.num_iters",
57+
"1",
58+
"--learning_parameters.batch_size",
59+
"4",
60+
],
4961
}
5062

5163
# Training params for resume, num_iters*2
@@ -118,7 +130,15 @@ def test_otx_resume(self, template, tmp_dir_path):
118130
_resume_params = resume_params.copy()
119131
# FIXME: remove this block once Issue#2504 resolved
120132
if "DINO" in template.name:
121-
_args["train_params"].extend(["--learning_parameters.input_size", "Default"])
133+
_args["train_params"] = [
134+
"params",
135+
"--learning_parameters.num_iters",
136+
"1",
137+
"--learning_parameters.batch_size",
138+
"4",
139+
"--learning_parameters.input_size",
140+
"Default",
141+
]
122142
_resume_params.extend(["--learning_parameters.input_size", "Default"])
123143
otx_resume_testing(template, tmp_dir_path, otx_dir, _args)
124144
template_work_dir = get_template_dir(template, tmp_dir_path)

0 commit comments

Comments
 (0)