Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Nov 15, 2024
1 parent 63fdf19 commit 9989bb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 4 additions & 9 deletions examples/post_training_quantization/openvino/yolov8/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9989bb5

Please sign in to comment.