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

Kp/fix e2e tests #3849

Merged
merged 14 commits into from
Aug 19, 2024
2 changes: 2 additions & 0 deletions .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
- task: "action"
- task: "classification"
- task: "detection"
- task: "rotated_detection"
- task: "keypoint_detection"
- task: "instance_segmentation"
- task: "semantic_segmentation"
- task: "visual_prompting"
Expand Down
57 changes: 38 additions & 19 deletions tests/e2e/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ def test_otx_e2e_cli(
Returns:
None
"""
task = recipe.split("/")[-2].upper()
model_name = recipe.split("/")[-1].split(".")[0]
recipe_split = recipe.split("/")
model_name = recipe_split[-1].split(".")[0]
is_semisl = model_name.endswith("_semisl")
task = recipe_split[-2].upper() if not is_semisl else recipe_split[-3].upper()

if task == OTXTaskType.INSTANCE_SEGMENTATION:
is_tiling = "tile" in recipe
dataset_path = fxt_target_dataset_per_task[task]["tiling" if is_tiling else "non_tiling"]
else:
dataset_path = fxt_target_dataset_per_task[task]

if isinstance(dataset_path, dict) and "supervised" in dataset_path:
dataset_path = dataset_path["supervised"]

# 1) otx train
tmp_path_train = tmp_path / f"otx_train_{model_name}"
command_cfg = [
Expand All @@ -71,6 +76,13 @@ def test_otx_e2e_cli(
*fxt_cli_override_command_per_task[task],
]

if is_semisl:
command_cfg.extend(
[
"--data.unlabeled_subset.data_root",
str(fxt_target_dataset_per_task[task]["unlabeled"]),
],
)
run_main(command_cfg=command_cfg, open_subprocess=fxt_open_subprocess)

outputs_dir = tmp_path_train / "outputs"
Expand Down Expand Up @@ -125,26 +137,24 @@ def test_otx_e2e_cli(
task_name in recipe
for task_name in [
"dino_v2",
"maskrcnn_r50_tv_tile",
eunwoosh marked this conversation as resolved.
Show resolved Hide resolved
]
):
return
if task in ("visual_prompting", "zero_shot_visual_prompting"):
fxt_export_list = [
ExportCase2Test("ONNX", False, "exported_model_decoder.onnx"),
ExportCase2Test("OPENVINO", False, "exported_model_decoder.xml"),
] # TODO (sungchul): EXPORTABLE_CODE will be supported
elif "anomaly" in task:
fxt_export_list = [
ExportCase2Test("ONNX", False, "exported_model.onnx"),
ExportCase2Test("OPENVINO", False, "exported_model.xml"),
] # anomaly doesn't support exportable code

overrides = fxt_cli_override_command_per_task[task]
if "anomaly" in task:
overrides = {} # Overrides are not needed in export

tmp_path_test = tmp_path / f"otx_test_{model_name}"
for export_case in fxt_export_list:
if (
eunwoosh marked this conversation as resolved.
Show resolved Hide resolved
task.lower() in ("visual_prompting", "zero_shot_visual_prompting", "keypoint_detection")
or task.lower().startswith("anomaly")
) and export_case.export_demo_package:
# Skip exportable code checking for visual_prompting, zero_shot_visual_prompting, anomaly and keypoint_detection tasks
return

command_cfg = [
"otx",
"export",
Expand Down Expand Up @@ -218,11 +228,9 @@ def test_otx_e2e_cli(
if ("_cls" not in task) and (task not in ["detection", "instance_segmentation"]):
return # Supported only for classification, detection and instance segmentation task.

if "dino" in model_name:
return # DINO is not supported.

if "rtdetr" in model_name:
return # RT-DETR currently is not supported.
unsupported_models = ["dino", "rtdetr"]
if any(model in model_name for model in unsupported_models):
return # The models are not supported.

tmp_path_test = tmp_path / f"otx_export_xai_{model_name}"
for export_case in fxt_export_list:
Expand Down Expand Up @@ -282,8 +290,13 @@ def test_otx_explain_e2e_cli(
"""
import cv2

task = recipe.split("/")[-2].upper()
model_name = recipe.split("/")[-1].split(".")[0]
recipe_split = recipe.split("/")
model_name = recipe_split[-1].split(".")[0]
is_semisl = model_name.endswith("_semisl")
task = recipe_split[-2].upper() if not is_semisl else recipe_split[-3].upper()

if is_semisl:
pytest.skip("SEMI-SL is not supported for explain.")

if task not in [
OTXTaskType.MULTI_CLASS_CLS,
Expand All @@ -303,6 +316,9 @@ def test_otx_explain_e2e_cli(
else:
dataset_path = fxt_target_dataset_per_task[task]

if isinstance(dataset_path, dict) and "supervised" in dataset_path:
dataset_path = dataset_path["supervised"]

if "dino" in model_name:
pytest.skip("DINO is not supported.")

Expand Down Expand Up @@ -422,6 +438,9 @@ def test_otx_hpo_e2e_cli(
else:
dataset_path = fxt_target_dataset_per_task[task]

if isinstance(dataset_path, dict) and "supervised" in dataset_path:
dataset_path = dataset_path["supervised"]

tmp_path_hpo = tmp_path / f"otx_hpo_{task.lower()}"
tmp_path_hpo.mkdir(parents=True)

Expand Down
20 changes: 14 additions & 6 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,33 @@ def pytest_configure(config):
@pytest.fixture()
def fxt_target_dataset_per_task(fxt_ci_data_root) -> dict:
return {
OTXTaskType.MULTI_CLASS_CLS: Path(fxt_ci_data_root / "v2/multiclass_classification/multiclass_CUB_small/1"),
OTXTaskType.MULTI_CLASS_CLS: {
"supervised": Path(fxt_ci_data_root / "v2/multiclass_classification/multiclass_CUB_small/1"),
"unlabeled": Path(fxt_ci_data_root / "v2/multiclass_classification/semi-sl/CUB_unlabeled"),
},
OTXTaskType.MULTI_LABEL_CLS: Path(fxt_ci_data_root / "v2/multilabel_classification/multilabel_CUB_small/1"),
OTXTaskType.H_LABEL_CLS: Path(fxt_ci_data_root / "v2/hlabel_classification/hlabel_CUB_small/1"),
OTXTaskType.DETECTION: Path(fxt_ci_data_root / "v2/detection/pothole_small/1"),
OTXTaskType.ROTATED_DETECTION: Path(fxt_ci_data_root / "v2/detection/pothole_small/1"),
OTXTaskType.DETECTION: Path(fxt_ci_data_root / "v2/detection/bdd_small/1"),
OTXTaskType.ROTATED_DETECTION: Path(fxt_ci_data_root / "v2/rotated_detection/subway"),
OTXTaskType.INSTANCE_SEGMENTATION: {
"non_tiling": Path(fxt_ci_data_root / "v2/instance_seg/wgisd_small/1"),
"tiling": Path(fxt_ci_data_root / "v2/tiling_instance_seg/vitens_aeromonas_small/1"),
},
OTXTaskType.SEMANTIC_SEGMENTATION: Path(fxt_ci_data_root / "v2/semantic_seg/kvasir_small/1"),
OTXTaskType.SEMANTIC_SEGMENTATION: {
"supervised": Path(fxt_ci_data_root / "v2/semantic_seg/kvasir_small/1"),
"unlabeled": Path(fxt_ci_data_root / "v2/semantic_seg/semi-sl/unlabeled_images/kvasir"),
},
OTXTaskType.ACTION_CLASSIFICATION: Path(
fxt_ci_data_root / "v2/action/action_classification/ucf_kinetics_5percent_small",
),
OTXTaskType.VISUAL_PROMPTING: Path(fxt_ci_data_root / "v2/visual_prompting/wgisd_small/1"),
OTXTaskType.VISUAL_PROMPTING: Path(fxt_ci_data_root / "v2/visual_prompting/coco_car_person_medium"),
OTXTaskType.ZERO_SHOT_VISUAL_PROMPTING: Path(
fxt_ci_data_root / "v2/zero_shot_visual_prompting/coco_car_person_medium",
),
OTXTaskType.ANOMALY_CLASSIFICATION: Path(fxt_ci_data_root / "v2/anomaly/mvtec/bottle_small/1"),
OTXTaskType.ANOMALY_CLASSIFICATION: Path(fxt_ci_data_root / "v2/anomaly/mvtec/hazelnut_large"),
OTXTaskType.ANOMALY_DETECTION: Path(fxt_ci_data_root / "v2/anomaly/mvtec/hazelnut_large"),
OTXTaskType.ANOMALY_SEGMENTATION: Path(fxt_ci_data_root / "v2/anomaly/mvtec/hazelnut_large"),
OTXTaskType.KEYPOINT_DETECTION: Path(fxt_ci_data_root / "v2/keypoint_detection/coco_keypoint_medium"),
}


Expand All @@ -126,4 +133,5 @@ def fxt_cli_override_command_per_task() -> dict:
OTXTaskType.ANOMALY_CLASSIFICATION: [],
OTXTaskType.ANOMALY_DETECTION: [],
OTXTaskType.ANOMALY_SEGMENTATION: [],
OTXTaskType.KEYPOINT_DETECTION: [],
}
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ task =
hlabel_classification: "hlabel_classification"
detection: "detection"
rotated_detection: "rotated_detection"
keypoint_detection: "keypoint_detection"
instance_segmentation: "instance_segmentation"
semantic_segmentation: "semantic_segmentation"
visual_prompting_all: "visual_prompting_all"
visual_prompting: "visual_prompting"
zero_shot_visual_prompting: "visual_prompting"
anomaly: "anomaly"
anomaly_classification: "anomaly_classification"
anomaly_detection: "anomaly_detection"
anomaly_segmentation: "anomaly_segmentation"
Expand Down Expand Up @@ -53,7 +55,7 @@ commands =
{posargs}


[testenv:integration-test-{all, action, classification, multi_cls_classification, multi_label_classification, hlabel_classification, detection, rotated_detection, instance_segmentation, semantic_segmentation, visual_prompting_all, visual_prompting, zero_shot_visual_prompting, anomaly_classification, anomaly_detection, anomaly_segmentation}]
[testenv:integration-test-{all, action, classification, multi_cls_classification, multi_label_classification, hlabel_classification, detection, rotated_detection, keypoint_detection, instance_segmentation, semantic_segmentation, visual_prompting_all, visual_prompting, zero_shot_visual_prompting, anomaly_classification, anomaly_detection, anomaly_segmentation}]
setenv =
CUBLAS_WORKSPACE_CONFIG=:4096:8
deps =
Expand All @@ -62,7 +64,7 @@ commands =
python -m pytest tests/integration -ra --showlocals --csv={toxworkdir}/{envname}.csv --task {[testenv]task} --open-subprocess {posargs}


[testenv:e2e-test-{all, action, classification, detection, rotated_detection, instance_segmentation, semantic_segmentation, visual_prompting, anomaly}]
[testenv:e2e-test-{all, action, classification, detection, rotated_detection, keypoint_detection, instance_segmentation, semantic_segmentation, visual_prompting, anomaly}]
setenv =
CUBLAS_WORKSPACE_CONFIG=:4096:8
deps =
Expand Down
Loading