From f9f4cb374c7e7531d36a2b7cb3cc97fc6f04523a Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Thu, 24 Oct 2024 12:35:27 +0100 Subject: [PATCH 1/7] Update ultralytics 8.2.83 --- .../onnx/yolov8_quantize_with_accuracy_control/main.py | 9 ++++----- .../requirements.txt | 2 +- .../post_training_quantization/openvino/yolov8/main.py | 5 +++-- .../openvino/yolov8/requirements.txt | 2 +- .../yolov8_quantize_with_accuracy_control/main.py | 9 ++++----- .../requirements.txt | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py index 38b4fe56ef5..db385d520a5 100644 --- a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py @@ -38,7 +38,7 @@ def validate( ) -> Tuple[Dict, int, int]: validator.seen = 0 validator.jdict = [] - validator.stats = [] + validator.stats = dict(tp_m=[], tp=[], conf=[], pred_cls=[], target_cls=[], target_img=[]) validator.batch_i = 1 validator.confusion_matrix = ConfusionMatrix(nc=validator.nc) @@ -101,13 +101,12 @@ def print_statistics(stats: np.ndarray, total_images: int, total_objects: int) - def prepare_validation(model: YOLO, args: Any) -> Tuple[Validator, torch.utils.data.DataLoader]: - validator = model.smart_load("validator")(args) + validator = model.task_map[model.task]["validator"](args=args) validator.data = check_det_dataset(args.data) + validator.stride = 32 data_loader = validator.get_dataloader(f"{DATASETS_DIR}/coco128-seg", 1) - validator = model.smart_load("validator")(args) - validator.is_coco = True validator.class_map = coco80_to_coco91_class() validator.names = model.model.names @@ -146,7 +145,7 @@ def validation_ac( ) -> float: validator.seen = 0 validator.jdict = [] - validator.stats = [] + validator.stats = dict(tp_m=[], tp=[], conf=[], pred_cls=[], target_cls=[], target_img=[]) validator.batch_i = 1 validator.confusion_matrix = ConfusionMatrix(nc=validator.nc) diff --git a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt index 39a2975bb85..278cb1ac49d 100644 --- a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt +++ b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt @@ -1,3 +1,3 @@ -ultralytics==8.0.170 +ultralytics==8.2.83 onnx==1.16.0 openvino==2024.4 diff --git a/examples/post_training_quantization/openvino/yolov8/main.py b/examples/post_training_quantization/openvino/yolov8/main.py index 7695c870b5e..1ec7b6b4a4d 100644 --- a/examples/post_training_quantization/openvino/yolov8/main.py +++ b/examples/post_training_quantization/openvino/yolov8/main.py @@ -36,7 +36,7 @@ def validate( ) -> Tuple[Dict, int, int]: validator.seen = 0 validator.jdict = [] - validator.stats = [] + validator.stats = dict(tp=[], conf=[], pred_cls=[], target_cls=[], target_img=[]) validator.confusion_matrix = ConfusionMatrix(nc=validator.nc) model.reshape({0: [1, 3, -1, -1]}) compiled_model = ov.compile_model(model, device_name="CPU") @@ -66,8 +66,9 @@ def print_statistics(stats: np.ndarray, total_images: int, total_objects: int) - def prepare_validation(model: YOLO, args: Any) -> Tuple[Validator, torch.utils.data.DataLoader]: - validator = model.smart_load("validator")(args) + validator = model.task_map[model.task]["validator"](args=args) validator.data = check_det_dataset(args.data) + validator.stride = 32 dataset = validator.data["val"] print(f"{dataset}") diff --git a/examples/post_training_quantization/openvino/yolov8/requirements.txt b/examples/post_training_quantization/openvino/yolov8/requirements.txt index d76435e18c4..c65d6c16ea4 100644 --- a/examples/post_training_quantization/openvino/yolov8/requirements.txt +++ b/examples/post_training_quantization/openvino/yolov8/requirements.txt @@ -1,3 +1,3 @@ -ultralytics==8.0.170 +ultralytics==8.2.83 onnx>=1.12.0,<1.16.2 openvino==2024.4 diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py index 919d1c0d7a1..dbcaf3ad6d4 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py @@ -38,7 +38,7 @@ def validate( ) -> Tuple[Dict, int, int]: validator.seen = 0 validator.jdict = [] - validator.stats = [] + validator.stats = dict(tp_m=[], tp=[], conf=[], pred_cls=[], target_cls=[], target_img=[]) validator.batch_i = 1 validator.confusion_matrix = ConfusionMatrix(nc=validator.nc) model.reshape({0: [1, 3, -1, -1]}) @@ -92,15 +92,14 @@ def print_statistics(stats: np.ndarray, total_images: int, total_objects: int) - def prepare_validation(model: YOLO, args: Any) -> Tuple[Validator, torch.utils.data.DataLoader]: - validator = model.smart_load("validator")(args) + validator = model.task_map[model.task]["validator"](args=args) validator.data = check_det_dataset(args.data) + validator.stride = 32 dataset = validator.data["val"] print(f"{dataset}") data_loader = validator.get_dataloader(f"{DATASETS_DIR}/coco128-seg", 1) - validator = model.smart_load("validator")(args) - validator.is_coco = True validator.class_map = coco80_to_coco91_class() validator.names = model.model.names @@ -146,7 +145,7 @@ def validation_ac( ) -> float: validator.seen = 0 validator.jdict = [] - validator.stats = [] + validator.stats = dict(tp_m=[], tp=[], conf=[], pred_cls=[], target_cls=[], target_img=[]) validator.batch_i = 1 validator.confusion_matrix = ConfusionMatrix(nc=validator.nc) num_outputs = len(compiled_model.outputs) diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt index d76435e18c4..c65d6c16ea4 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt @@ -1,3 +1,3 @@ -ultralytics==8.0.170 +ultralytics==8.2.83 onnx>=1.12.0,<1.16.2 openvino==2024.4 From 0375511f088ffd93d5513d36284230b26ba55ab2 Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Fri, 25 Oct 2024 12:00:30 +0100 Subject: [PATCH 2/7] Minor fix --- .../onnx/yolov8_quantize_with_accuracy_control/deploy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/deploy.py b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/deploy.py index 555709a103f..b1b5a7a8c9f 100644 --- a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/deploy.py +++ b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/deploy.py @@ -42,7 +42,7 @@ def validate_ov_model( ) -> Tuple[Dict, int, int]: validator.seen = 0 validator.jdict = [] - validator.stats = [] + validator.stats = dict(tp_m=[], tp=[], conf=[], pred_cls=[], target_cls=[], target_img=[]) validator.batch_i = 1 validator.confusion_matrix = ConfusionMatrix(nc=validator.nc) compiled_model = ov.compile_model(ov_model, device_name="CPU") From b5f90a6d5e16229ce280293d175f54db55e4c41f Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Fri, 25 Oct 2024 14:37:36 +0100 Subject: [PATCH 3/7] change version --- .../onnx/yolov8_quantize_with_accuracy_control/requirements.txt | 2 +- .../post_training_quantization/openvino/yolov8/requirements.txt | 2 +- .../yolov8_quantize_with_accuracy_control/requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt index 278cb1ac49d..8ca740c81eb 100644 --- a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt +++ b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/requirements.txt @@ -1,3 +1,3 @@ -ultralytics==8.2.83 +ultralytics==8.3.22 onnx==1.16.0 openvino==2024.4 diff --git a/examples/post_training_quantization/openvino/yolov8/requirements.txt b/examples/post_training_quantization/openvino/yolov8/requirements.txt index c65d6c16ea4..6eff61e282b 100644 --- a/examples/post_training_quantization/openvino/yolov8/requirements.txt +++ b/examples/post_training_quantization/openvino/yolov8/requirements.txt @@ -1,3 +1,3 @@ -ultralytics==8.2.83 +ultralytics==8.3.22 onnx>=1.12.0,<1.16.2 openvino==2024.4 diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt index c65d6c16ea4..6eff61e282b 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/requirements.txt @@ -1,3 +1,3 @@ -ultralytics==8.2.83 +ultralytics==8.3.22 onnx>=1.12.0,<1.16.2 openvino==2024.4 From 4c80e28c7ae361ed8e9ae1e7c150d5e16824f192 Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Wed, 30 Oct 2024 14:57:05 +0000 Subject: [PATCH 4/7] minor fix --- .../openvino/yolov8_quantize_with_accuracy_control/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py index dbcaf3ad6d4..abdcb982d12 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py @@ -210,6 +210,7 @@ def main(): model = YOLO(f"{ROOT}/{MODEL_NAME}.pt") args = get_cfg(cfg=DEFAULT_CFG) args.data = "coco128-seg.yaml" + args.workers = 0 # Prepare validation dataset and helper validator, data_loader = prepare_validation(model, args) From b980cdbe2186bfc4ca543adac291d66a795a93d4 Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Thu, 31 Oct 2024 13:24:48 +0000 Subject: [PATCH 5/7] minor fix --- tests/cross_fw/examples/test_examples.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cross_fw/examples/test_examples.py b/tests/cross_fw/examples/test_examples.py index 5b47b74533a..7aa62d0eca8 100644 --- a/tests/cross_fw/examples/test_examples.py +++ b/tests/cross_fw/examples/test_examples.py @@ -81,6 +81,7 @@ def test_examples( env["PYTHONPATH"] = str(PROJECT_ROOT) # need this to be able to import from tests.* in run_example.py env["ONEDNN_MAX_CPU_ISA"] = "AVX2" # Set ISA to AVX2 to get CPU independent results env["CUDA_VISIBLE_DEVICES"] = "" # Disable GPU + env.environ['YOLO_VERBOSE'] = "False" # Set ultralytics to quiet mode metrics_file_path = tmp_path / "metrics.json" python_executable_with_venv = get_python_executable_with_venv(venv_path) From c6c5a516baa950dd10f027a43edc0eea913c6e7d Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Thu, 31 Oct 2024 13:30:48 +0000 Subject: [PATCH 6/7] fix --- tests/cross_fw/examples/test_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cross_fw/examples/test_examples.py b/tests/cross_fw/examples/test_examples.py index 7aa62d0eca8..05a0c77c610 100644 --- a/tests/cross_fw/examples/test_examples.py +++ b/tests/cross_fw/examples/test_examples.py @@ -81,7 +81,7 @@ def test_examples( env["PYTHONPATH"] = str(PROJECT_ROOT) # need this to be able to import from tests.* in run_example.py env["ONEDNN_MAX_CPU_ISA"] = "AVX2" # Set ISA to AVX2 to get CPU independent results env["CUDA_VISIBLE_DEVICES"] = "" # Disable GPU - env.environ['YOLO_VERBOSE'] = "False" # Set ultralytics to quiet mode + env['YOLO_VERBOSE'] = "False" # Set ultralytics to quiet mode metrics_file_path = tmp_path / "metrics.json" python_executable_with_venv = get_python_executable_with_venv(venv_path) From 274e63ebdc854a76f454a2dde0731f6ee9f1e1ea Mon Sep 17 00:00:00 2001 From: Andrey Churkin Date: Thu, 31 Oct 2024 16:16:49 +0000 Subject: [PATCH 7/7] add fix --- tests/cross_fw/examples/test_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cross_fw/examples/test_examples.py b/tests/cross_fw/examples/test_examples.py index 05a0c77c610..486a20aa45f 100644 --- a/tests/cross_fw/examples/test_examples.py +++ b/tests/cross_fw/examples/test_examples.py @@ -81,7 +81,7 @@ def test_examples( env["PYTHONPATH"] = str(PROJECT_ROOT) # need this to be able to import from tests.* in run_example.py env["ONEDNN_MAX_CPU_ISA"] = "AVX2" # Set ISA to AVX2 to get CPU independent results env["CUDA_VISIBLE_DEVICES"] = "" # Disable GPU - env['YOLO_VERBOSE'] = "False" # Set ultralytics to quiet mode + env["YOLO_VERBOSE"] = "False" # Set ultralytics to quiet mode metrics_file_path = tmp_path / "metrics.json" python_executable_with_venv = get_python_executable_with_venv(venv_path)