-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add perf benchmark test cases for action and visual prompting v1 (#3292)
* Run command w/ subprocess.run() for better stability * Collect raw data to get seed info * Fix model-category default to all * Add action perf test cases * Add visual prompting perf test cases * Fix pre-commit
- Loading branch information
1 parent
a999372
commit 0996359
Showing
5 changed files
with
400 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
"""OTX Action perfomance tests.""" | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import pytest | ||
|
||
from otx.cli.registry import Registry | ||
from typing import Callable | ||
from .benchmark import Benchmark | ||
|
||
|
||
class TestPerfActionClassification: | ||
"""Benchmark action classification.""" | ||
|
||
MODEL_TEMPLATES = Registry(f"src/otx/algorithms").filter(task_type="ACTION_CLASSIFICATION").templates | ||
MODEL_IDS = [template.model_template_id for template in MODEL_TEMPLATES] | ||
|
||
BENCHMARK_CONFIGS = { | ||
"small": { | ||
"tags": { | ||
"task": "action_classification", | ||
}, | ||
"datasets": [ | ||
"action/action_classification/ucf_cvat_5percent", | ||
], | ||
"num_repeat": 5, | ||
"num_epoch": 10, | ||
}, | ||
"medium": { | ||
"tags": { | ||
"task": "action_classification", | ||
}, | ||
"datasets": [ | ||
"action/action_classification/ucf_cvat_30percent", | ||
], | ||
"num_repeat": 5, | ||
"num_epoch": 10, | ||
}, | ||
"large": { | ||
"tags": { | ||
"task": "action_classification", | ||
}, | ||
"datasets": [ | ||
"action/action_classification/ucf_cvat", | ||
], | ||
"num_repeat": 5, | ||
"num_epoch": 3, | ||
}, | ||
} | ||
|
||
@pytest.mark.parametrize("fxt_model_id", MODEL_TEMPLATES, ids=MODEL_IDS, indirect=True) | ||
@pytest.mark.parametrize("fxt_benchmark", BENCHMARK_CONFIGS.items(), ids=BENCHMARK_CONFIGS.keys(), indirect=True) | ||
def test_perf(self, fxt_model_id: str, fxt_benchmark: Benchmark): | ||
"""Benchmark performance metrics.""" | ||
result = fxt_benchmark.run(model_id=fxt_model_id) | ||
fxt_benchmark.check( | ||
result, | ||
criteria=[ | ||
{ | ||
"name": "Accuracy(train)", | ||
"op": ">", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "Accuracy(export)", | ||
"op": ">", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "Accuracy(optimize)", | ||
"op": ">", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "epoch", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "train_e2e_time", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_data_time", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_iter_time", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_time_per_image(export)", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_time_per_image(optimize)", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
], | ||
) | ||
|
||
|
||
class TestPerfActionDetection: | ||
"""Benchmark action detection.""" | ||
|
||
MODEL_TEMPLATES = Registry(f"src/otx/algorithms").filter(task_type="ACTION_DETECTION").templates | ||
MODEL_IDS = [template.model_template_id for template in MODEL_TEMPLATES] | ||
|
||
BENCHMARK_CONFIGS = { | ||
"small": { | ||
"tags": { | ||
"task": "action_detection", | ||
}, | ||
"datasets": [ | ||
"action/action_detection/UCF101_cvat_5percent", | ||
], | ||
"num_repeat": 5, | ||
"num_epoch": 3, | ||
}, | ||
"medium": { | ||
"tags": { | ||
"task": "action_detection", | ||
}, | ||
"datasets": [ | ||
"action/action_detection/UCF101_cvat_30percent", | ||
], | ||
"num_repeat": 5, | ||
"num_epoch": 3, | ||
}, | ||
"large": { | ||
"tags": { | ||
"task": "action_detection", | ||
}, | ||
"datasets": [ | ||
"action/action_detection/UCF101_cvat", | ||
], | ||
"num_repeat": 5, | ||
"num_epoch": 1, | ||
}, | ||
} | ||
|
||
@pytest.mark.parametrize("fxt_model_id", MODEL_TEMPLATES, ids=MODEL_IDS, indirect=True) | ||
@pytest.mark.parametrize("fxt_benchmark", BENCHMARK_CONFIGS.items(), ids=BENCHMARK_CONFIGS.keys(), indirect=True) | ||
def test_perf(self, fxt_model_id: str, fxt_benchmark: Benchmark): | ||
"""Benchmark performance metrics.""" | ||
result = fxt_benchmark.run(model_id=fxt_model_id) | ||
fxt_benchmark.check( | ||
result, | ||
criteria=[ | ||
{ | ||
"name": "f-measure(train)", | ||
"op": ">", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "epoch", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "f-measure(export)", | ||
"op": ">", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "f-measure(optimize)", | ||
"op": ">", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "train_e2e_time", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_data_time", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_iter_time", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_time_per_image(export)", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
{ | ||
"name": "avg_time_per_image(optimize)", | ||
"op": "<", | ||
"margin": 0.1, | ||
}, | ||
], | ||
) |
Oops, something went wrong.