From 9989bb5a0ee635d12b7a81c9f77631c2a045b0d1 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 15 Nov 2024 16:27:52 +0200 Subject: [PATCH] t --- .../yolov8_quantize_with_accuracy_control/main.py | 14 ++++---------- .../openvino/yolov8/main.py | 13 ++++--------- .../yolov8_quantize_with_accuracy_control/main.py | 10 ++-------- 3 files changed, 10 insertions(+), 27 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 e96e6138636..591b425a147 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 @@ -16,26 +16,22 @@ import onnx import onnxruntime import torch -import ultralytics.utils as ul_utils from ultralytics.cfg import get_cfg from ultralytics.data.converter import coco80_to_coco91_class from ultralytics.data.utils import check_det_dataset from ultralytics.models.yolo import YOLO from ultralytics.models.yolo.segment.val import SegmentationValidator +from ultralytics.utils import DATASETS_DIR from ultralytics.utils import DEFAULT_CFG -from ultralytics.utils import SETTINGS from ultralytics.utils import ops from ultralytics.utils.metrics import ConfusionMatrix import nncf from nncf.common.logging.track_progress import track -ROOT = Path(__file__).parent.resolve() -DATASET_PATH = Path().home() / ".cache" / "nncf" / "datasets" +MODEL_NAME = "yolov8n-seg" -# Overwrite dataset path to avoid downloading COCO dataset to NNCF git root directory -SETTINGS.update(datasets_dir=DATASET_PATH.as_posix()) -ul_utils.DATASETS_DIR = DATASET_PATH +ROOT = Path(__file__).parent.resolve() def validate( @@ -118,7 +114,7 @@ def prepare_validation(model: YOLO, args: Any) -> Tuple[SegmentationValidator, t validator.process = ops.process_mask validator.plot_masks = [] - coco_data_path = DATASET_PATH / "coco128-seg" + coco_data_path = DATASETS_DIR / "coco128-seg" data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) return validator, data_loader @@ -218,8 +214,6 @@ def validation_ac( def run_example(): - MODEL_NAME = "yolov8n-seg" - model = YOLO(ROOT / f"{MODEL_NAME}.pt") args = get_cfg(cfg=DEFAULT_CFG) args.data = "coco128-seg.yaml" diff --git a/examples/post_training_quantization/openvino/yolov8/main.py b/examples/post_training_quantization/openvino/yolov8/main.py index 3adc242c6cd..008b93b030e 100644 --- a/examples/post_training_quantization/openvino/yolov8/main.py +++ b/examples/post_training_quantization/openvino/yolov8/main.py @@ -15,13 +15,13 @@ import openvino as ov import torch -import ultralytics.utils as ul_utils from ultralytics.cfg import get_cfg from ultralytics.data.converter import coco80_to_coco91_class from ultralytics.data.utils import check_det_dataset from ultralytics.models.yolo import YOLO from ultralytics.models.yolo.detect.val import DetectionValidator -from ultralytics.utils import SETTINGS +from ultralytics.utils import DATASETS_DIR +from ultralytics.utils import DEFAULT_CFG from ultralytics.utils.metrics import ConfusionMatrix import nncf @@ -30,11 +30,6 @@ MODEL_NAME = "yolov8n" ROOT = Path(__file__).parent.resolve() -DATASET_PATH = Path().home() / ".cache" / "nncf" / "datasets" - -# Overwrite dataset path to avoid downloading COCO dataset to NNCF git root directory -SETTINGS.update(datasets_dir=DATASET_PATH.as_posix()) -ul_utils.DATASETS_DIR = DATASET_PATH def validate( @@ -81,7 +76,7 @@ def prepare_validation(model: YOLO, args: Any) -> Tuple[DetectionValidator, torc validator.metrics.names = validator.names validator.nc = model.model.model[-1].nc - coco_data_path = DATASET_PATH / "coco128" + coco_data_path = DATASETS_DIR / "coco128" data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) return validator, data_loader @@ -141,7 +136,7 @@ def transform_fn(data_item: Dict): def main(): model = YOLO(ROOT / f"{MODEL_NAME}.pt") - args = get_cfg(cfg=ul_utils.DEFAULT_CFG) + args = get_cfg(cfg=DEFAULT_CFG) args.data = "coco128.yaml" # Prepare validation dataset and helper 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 adb13e204e5..91d89dfbff0 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 @@ -16,14 +16,13 @@ import openvino as ov import torch -import ultralytics.utils as ul_utils from ultralytics.cfg import get_cfg from ultralytics.data.converter import coco80_to_coco91_class from ultralytics.data.utils import check_det_dataset from ultralytics.models.yolo import YOLO from ultralytics.models.yolo.segment.val import SegmentationValidator +from ultralytics.utils import DATASETS_DIR from ultralytics.utils import DEFAULT_CFG -from ultralytics.utils import SETTINGS from ultralytics.utils import ops from ultralytics.utils.metrics import ConfusionMatrix @@ -33,11 +32,6 @@ MODEL_NAME = "yolov8n-seg" ROOT = Path(__file__).parent.resolve() -DATASET_PATH = Path().home() / ".cache" / "nncf" / "datasets" - -# Overwrite dataset path to avoid downloading COCO dataset to NNCF git root directory -SETTINGS.update(datasets_dir=DATASET_PATH.as_posix()) -ul_utils.DATASETS_DIR = DATASET_PATH def validate( @@ -108,7 +102,7 @@ def prepare_validation(model: YOLO, args: Any) -> Tuple[SegmentationValidator, t validator.process = ops.process_mask validator.plot_masks = [] - coco_data_path = DATASET_PATH / "coco128-seg" + coco_data_path = DATASETS_DIR / "coco128-seg" data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) return validator, data_loader