Skip to content

Commit

Permalink
update as per yolov8 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dsikka committed Jul 21, 2023
1 parent fb9d131 commit 19ad588
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _parse_requirements_file(file_path):
"pycocotools >=2.0.6",
"scipy==1.10.1",
]
_yolov8_integration_deps = _yolo_integration_deps + ["ultralytics==8.0.30"]
_yolov8_integration_deps = _yolo_integration_deps + ["ultralytics==8.0.124"]
_transformers_integration_deps = [
f"{'nm-transformers' if is_release else 'nm-transformers-nightly'}"
f"~={version_base}",
Expand Down
23 changes: 13 additions & 10 deletions src/deepsparse/yolov8/utils/validation/deepsparse_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ultralytics.yolo.utils import (
DEFAULT_CFG,
LOGGER,
RANK,
SETTINGS,
TQDM_BAR_FORMAT,
callbacks,
Expand All @@ -39,10 +38,10 @@ def __call__(self, classes: Dict[int, str]):
"""
# deepsparse edit: removed the if-statement responsible
# for validation when self.training is True
callbacks.add_integration_callbacks(self)
callbacks.add_integration_callbacks(self) # TODO: Missing inputs?
self.run_callbacks("on_val_start")
self.device = select_device(self.args.device, self.args.batch)
self.args.half &= self.device.type != "cpu"
self.device = select_device(self.args.device, self.args.batch) # TODO: Fix
# self.args.half &= self.device.type != "cpu" # TODO: not commented out here?
self.data = check_det_dataset(self.args.data)
if isinstance(self.data["path"], str):
self.data["path"] = Path(self.data["path"])
Expand All @@ -53,7 +52,7 @@ def __call__(self, classes: Dict[int, str]):
)

self.dataloader = self.dataloader or self.get_dataloader(
self.data.get("val") or self.data.set("test"), self.args.batch
self.data.get(self.args.split), self.args.batch
)

dt = Profile(), Profile(), Profile(), Profile()
Expand Down Expand Up @@ -93,18 +92,22 @@ def __call__(self, classes: Dict[int, str]):
stats = self.get_stats()
self.check_stats(stats)
self.print_results()
self.speed = tuple(
x.t / len(self.dataloader.dataset) * 1e3 for x in dt
self.speed = dict(
zip(
self.speed.keys(),
(x.t / len(self.dataloader.dataset) * 1e3 for x in dt),
)
) # speeds per image
self.finalize_metrics()
self.run_callbacks("on_val_end")

self.logger.info(
LOGGER.info(
"Speed: %.1fms pre-process, %.1fms inference, %.1fms loss, %.1fms post-process per image"
% self.speed
% tuple(self.speed.values())
)
if self.args.save_json and self.jdict:
with open(str(self.save_dir / "predictions.json"), "w") as f:
self.logger.info(f"Saving {f.name}...")
LOGGER.info(f"Saving {f.name}...")
json.dump(self.jdict, f) # flatten and save
stats = self.eval_json(stats) # update stats
return stats
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ def __init__(
dataloader=None,
save_dir=None,
pbar=None,
logger=None,
args=None,
):
DetectionValidator.__init__(self, dataloader, save_dir, pbar, logger, args)
DetectionValidator.__init__(self, dataloader, save_dir, pbar, args)
DeepSparseValidator.__init__(self, pipeline)

# deepsparse edit: replaced argument `model` with `classes`
Expand Down

0 comments on commit 19ad588

Please sign in to comment.