From 1d62b66e0799912679576a559382635a38e1f5a8 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 15 Nov 2024 18:11:22 +0200 Subject: [PATCH] mkdir --- .../yolov8_quantize_with_accuracy_control/main.py | 10 +++++----- .../openvino/yolov8/main.py | 12 ++++++------ .../yolov8_quantize_with_accuracy_control/main.py | 10 +++++----- 3 files changed, 16 insertions(+), 16 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 d315fee858c..a70206ac87e 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 @@ -34,7 +34,6 @@ ROOT = Path(__file__).parent.resolve() DATASET_PATH = Path().home() / ".cache" / "nncf" / "datasets" -DATASET_PATH.mkdir(parents=True, exist_ok=True) # Overwrite dataset path to avoid downloading COCO dataset to NNCF git root directory SETTINGS.update(datasets_dir=DATASET_PATH.as_posix()) @@ -110,13 +109,12 @@ def print_statistics(stats: Dict[str, float], total_images: int, total_objects: def prepare_validation(model: YOLO, args: Any) -> Tuple[SegmentationValidator, torch.utils.data.DataLoader]: + coco_data_path = DATASET_PATH / "coco128-seg" + coco_data_path.mkdir(parents=True, exist_ok=True) + validator: SegmentationValidator = model.task_map[model.task]["validator"](args=args) validator.data = check_det_dataset(args.data) validator.stride = 32 - - coco_data_path = DATASET_PATH / "coco128-seg" - data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) - validator.is_coco = True validator.class_map = coco80_to_coco91_class() validator.names = model.model.names @@ -125,6 +123,8 @@ def prepare_validation(model: YOLO, args: Any) -> Tuple[SegmentationValidator, t validator.process = ops.process_mask validator.plot_masks = [] + data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) + return validator, data_loader diff --git a/examples/post_training_quantization/openvino/yolov8/main.py b/examples/post_training_quantization/openvino/yolov8/main.py index 91f8272a029..d1d2b96e892 100644 --- a/examples/post_training_quantization/openvino/yolov8/main.py +++ b/examples/post_training_quantization/openvino/yolov8/main.py @@ -30,8 +30,7 @@ MODEL_NAME = "yolov8n" ROOT = Path(__file__).parent.resolve() -DATASET_PATH = Path().home() / ".cache" / "nncf" / "datasets" -DATASET_PATH.mkdir(parents=True, exist_ok=True) +DATASET_PATH = Path().home() / ".cache3" / "nncf" / "datasets" # Overwrite dataset path to avoid downloading COCO dataset to NNCF git root directory SETTINGS.update(datasets_dir=DATASET_PATH.as_posix()) @@ -73,19 +72,20 @@ def print_statistics(stats: Dict[str, float], total_images: int, total_objects: def prepare_validation(model: YOLO, args: Any) -> Tuple[DetectionValidator, torch.utils.data.DataLoader]: + coco_data_path = DATASET_PATH / "coco128" + coco_data_path.mkdir(parents=True, exist_ok=True) + validator: DetectionValidator = model.task_map[model.task]["validator"](args=args) validator.data = check_det_dataset(args.data) validator.stride = 32 - - coco_data_path = DATASET_PATH / "coco128" - data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) - validator.is_coco = True validator.class_map = coco80_to_coco91_class() validator.names = model.model.names validator.metrics.names = validator.names validator.nc = model.model.model[-1].nc + data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) + return validator, data_loader 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 269a257a87e..767cb9618fa 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 @@ -34,7 +34,6 @@ ROOT = Path(__file__).parent.resolve() DATASET_PATH = Path().home() / ".cache" / "nncf" / "datasets" -DATASET_PATH.mkdir(parents=True, exist_ok=True) # Overwrite dataset path to avoid downloading COCO dataset to NNCF git root directory SETTINGS.update(datasets_dir=DATASET_PATH.as_posix()) @@ -98,13 +97,12 @@ def print_statistics(stats: Dict[str, float], total_images: int, total_objects: def prepare_validation(model: YOLO, args: Any) -> Tuple[SegmentationValidator, torch.utils.data.DataLoader]: + coco_data_path = DATASET_PATH / "coco128-seg" + coco_data_path.mkdir(parents=True, exist_ok=True) + validator: SegmentationValidator = model.task_map[model.task]["validator"](args=args) validator.data = check_det_dataset(args.data) validator.stride = 32 - - coco_data_path = DATASET_PATH / "coco128-seg" - data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) - validator.is_coco = True validator.class_map = coco80_to_coco91_class() validator.names = model.model.names @@ -113,6 +111,8 @@ def prepare_validation(model: YOLO, args: Any) -> Tuple[SegmentationValidator, t validator.process = ops.process_mask validator.plot_masks = [] + data_loader = validator.get_dataloader(coco_data_path.as_posix(), 1) + return validator, data_loader