Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test for visual prompting #2360

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3ce1e43
(WIP) otx optimize
sungchul2 Jul 12, 2023
4ba2e05
pre-commit
sungchul2 Jul 13, 2023
ba8b5ec
(WIP) set e2e
sungchul2 Jul 14, 2023
6c10c56
Remove nncf config
sungchul2 Jul 14, 2023
348ad47
Add visual prompting requirement
sungchul2 Jul 14, 2023
f37941b
Add visual prompting in tox
sungchul2 Jul 14, 2023
23463a8
Add visual prompting in setup.py
sungchul2 Jul 14, 2023
2c17d86
Fix typo
sungchul2 Jul 14, 2023
883c5ef
Delete unused configuration.yaml
sungchul2 Jul 14, 2023
95b44fe
Edit test_name
sungchul2 Jul 14, 2023
9ed3c56
Add to limit activation range
sungchul2 Jul 14, 2023
8f91aa7
Update from `vp` to `visprompt`
sungchul2 Jul 14, 2023
28ef2ff
Fix about no returning the first label
sungchul2 Jul 14, 2023
6e87888
pre-commit
sungchul2 Jul 14, 2023
09e4e7b
(WIP) otx optimize
sungchul2 Jul 12, 2023
e3386f6
pre-commit
sungchul2 Jul 13, 2023
39279bf
(WIP) set e2e
sungchul2 Jul 14, 2023
9e3edae
Remove nncf config
sungchul2 Jul 14, 2023
0ce118a
Add visual prompting requirement
sungchul2 Jul 14, 2023
bfb3ab0
Add visual prompting in tox
sungchul2 Jul 14, 2023
4797774
Add visual prompting in setup.py
sungchul2 Jul 14, 2023
f0ae8e8
Fix typo
sungchul2 Jul 14, 2023
9926b72
pre-commit
sungchul2 Jul 17, 2023
69006b5
Merge branch 'releases/1.4.0' into visual-prompting-e2e
sungchul2 Jul 17, 2023
cf28d15
Add actions
sungchul2 Jul 17, 2023
9989f49
Merge branch 'visual-prompting-e2e' of https://github.com/sungchul2/t…
sungchul2 Jul 17, 2023
97aa302
Update tests/e2e/cli/visual_prompting/test_visual_prompting.py
sungchul2 Jul 17, 2023
1d99ff4
Fix
sungchul2 Jul 17, 2023
5819ef7
Merge branch 'visual-prompting-e2e' of https://github.com/sungchul2/t…
sungchul2 Jul 17, 2023
ce522a1
Skip PTQ e2e test
sungchul2 Jul 17, 2023
64cd0f1
Change task name
sungchul2 Jul 17, 2023
2cf4828
Remove skipped tc
sungchul2 Jul 17, 2023
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: 2 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
test_dir: "tests/e2e/cli/instance_segmentation"
- task: "seg"
test_dir: "tests/e2e/cli/semantic_segmentation"
- task: "visprompt"
test_dir: "tests/e2e/cli/visual_prompting"
name: E2E-Test-py310-${{ matrix.task }}
uses: ./.github/workflows/run_tests_in_tox.yml
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pre_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ jobs:
test_dir: "tests/integration/cli/action"
- task: "ano"
test_dir: "tests/integration/cli/anomaly"
- task: "visprompt"
test_dir: "tests/integration/cli/visual_prompting"
name: Integration-Test-py310-${{ matrix.task }}
# This is what will cancel the job concurrency
concurrency:
Expand Down
4 changes: 4 additions & 0 deletions requirements/visual_prompting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Visual Prompting Requirements.
scikit-image
pytorch-lightning>=1.7.0,<1.10.0
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,18 @@ def _cython_modules():
"base", "openvino", "segmentation",
]
),
"visual_prompting": get_requirements(requirement_files=[
"base", "openvino", "visual_prompting",
]
),
"full": get_requirements(requirement_files=[
"base",
"openvino",
"anomaly",
"classification",
"detection",
"segmentation",
"visual_prompting",
"action",
]
),
Expand Down
56 changes: 0 additions & 56 deletions src/otx/algorithms/visual_prompting/configs/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,62 +85,6 @@ learning_parameters:
visible_in_ui: true
warning: null
auto_hpo_state: NOT_POSSIBLE
nncf_optimization:
description: Optimization by NNCF
enable_pruning:
affects_outcome_of: NONE
auto_hpo_state: not_possible
auto_hpo_value: null
default_value: false
description: Enable filter pruning algorithm
editable: true
header: Enable filter pruning algorithm
type: BOOLEAN
ui_rules:
action: DISABLE_EDITING
operator: AND
rules: []
type: UI_RULES
value: false
visible_in_ui: true
warning: null
enable_quantization:
affects_outcome_of: NONE
auto_hpo_state: not_possible
auto_hpo_value: null
default_value: true
description: Enable quantization algorithm
editable: true
header: Enable quantization algorithm
type: BOOLEAN
ui_rules:
action: DISABLE_EDITING
operator: AND
rules: []
type: UI_RULES
value: true
visible_in_ui: true
warning: null
header: Optimization by NNCF
pruning_supported:
affects_outcome_of: TRAINING
auto_hpo_state: not_possible
auto_hpo_value: null
default_value: false
description: Whether filter pruning is supported
editable: false
header: Whether filter pruning is supported
type: BOOLEAN
ui_rules:
action: DISABLE_EDITING
operator: AND
rules: []
type: UI_RULES
value: false
visible_in_ui: false
warning: null
type: PARAMETER_GROUP
visible_in_ui: true
pot_parameters:
description: POT Parameters
header: POT Parameters
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""PTQ config file."""
from nncf.common.quantization.structs import QuantizationPreset
from nncf.quantization.advanced_parameters import AdvancedQuantizationParameters
from nncf.quantization.range_estimator import (
AggregatorType,
RangeEstimatorParameters,
StatisticsCollectorParameters,
StatisticsType,
)

advanced_parameters = AdvancedQuantizationParameters(
activations_range_estimator_params=RangeEstimatorParameters(
min=StatisticsCollectorParameters(
statistics_type=StatisticsType.QUANTILE, aggregator_type=AggregatorType.MIN, quantile_outlier_prob=1e-4
),
max=StatisticsCollectorParameters(
statistics_type=StatisticsType.QUANTILE, aggregator_type=AggregatorType.MAX, quantile_outlier_prob=1e-4
),
),
# backend_params={"use_pot": True},
)

preset = QuantizationPreset.MIXED
17 changes: 11 additions & 6 deletions src/otx/algorithms/visual_prompting/tasks/openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import nncf
import numpy as np
import openvino.runtime as ov
from addict import Dict as ADDict
from nncf.common.quantization.structs import QuantizationPreset
from openvino.model_api.adapters import OpenvinoAdapter, create_core
from openvino.model_api.models import Model

from otx.algorithms.common.utils import get_default_async_reqs_num, read_py_config
from otx.algorithms.common.utils.ir import check_if_quantized
from otx.algorithms.common.utils.logger import get_logger
from otx.algorithms.common.utils.utils import get_default_async_reqs_num
from otx.algorithms.visual_prompting.adapters.openvino import model_wrappers
from otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset import (
OTXVisualPromptingDataset,
Expand Down Expand Up @@ -447,13 +448,17 @@ def optimize(
if optimization_parameters is not None:
optimization_parameters.update_progress(10 * i + 35 * (i - 1), None)

stat_subset_size = self.hparams.pot_parameters.stat_subset_size
preset = QuantizationPreset(self.hparams.pot_parameters.preset.name.lower())

compressed_model = nncf.quantize(
ov_model, quantization_dataset, subset_size=min(stat_subset_size, len(data_loader)), preset=preset
optimization_config_path = os.path.join(self._base_dir, "ptq_optimization_config.py")
ptq_config = ADDict()
if os.path.exists(optimization_config_path):
ptq_config = read_py_config(optimization_config_path)
ptq_config.update(
subset_size=min(self.hparams.pot_parameters.stat_subset_size, len(data_loader)),
preset=QuantizationPreset(self.hparams.pot_parameters.preset.name.lower()),
)

compressed_model = nncf.quantize(ov_model, quantization_dataset, **ptq_config)

if optimization_parameters is not None:
optimization_parameters.update_progress(45 * i, None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_otx_dataset(self) -> DatasetEntity:
if self.use_mask:
# use masks loaded in datumaro as-is
if self.data_type == "common_semantic_segmentation":
if new_label := self.updated_label_id.get(ann.label, None):
if (new_label := self.updated_label_id.get(ann.label, None)) is not None:
ann.label = new_label
else:
continue
Expand All @@ -70,7 +70,7 @@ def get_otx_dataset(self) -> DatasetEntity:
# convert masks to polygons, they will be converted to masks again
datumaro_polygons = MasksToPolygons.convert_mask(ann)
for d_polygon in datumaro_polygons:
if new_label := self.updated_label_id.get(d_polygon.label, None):
if (new_label := self.updated_label_id.get(d_polygon.label, None)) is not None:
d_polygon.label = new_label
else:
continue
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/cli/visual_prompting/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TestToolsVisualPrompting:
pot:
number_of_fakequantizers: 210
Loading