Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YOLOV8] Update version #1138

Merged
merged 8 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _parse_requirements_file(file_path):
"opencv-python<=4.6.0.66",
]
_yolo_integration_deps = [
"torchvision>=0.3.0,<0.14",
"torchvision>=0.3.0,<=0.15.1",
dsikka marked this conversation as resolved.
Show resolved Hide resolved
"opencv-python<=4.6.0.66",
]
_openpifpaf_integration_deps = [
Expand All @@ -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
14 changes: 4 additions & 10 deletions src/deepsparse/yolov8/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,14 @@ def process_engine_outputs(
)

def process_engine_outputs_seg(
self, engine_outputs: List[numpy.ndarray], nm: int = 32, **kwargs
self, engine_outputs: List[numpy.ndarray], nc: int = 80, **kwargs
) -> YOLOSegOutput:
"""
The pathway for processing the outputs of the engine for YOLOv8 segmentation.
:param engine_outputs: list of numpy arrays that are the output of the engine
forward pass
:param nm: number of mask protos. It is information needed to perform NMS on the
segmentation output. It can be calculated in the following way:
dims = bboxes + classes + nm
where:
- bboxes = 4
- classes = 80 (explicit assumption -> we are using COCO dataset)
- dims = 116 (comes from the fact that
detection.shape == [B, dims, 8400])
: params nc: number of classes. If not provided, calculated as
detection.shape[1] - 4
:return: outputs of engine post-processed into an object in the `output_schema`
format of this pipeline
"""
Expand All @@ -131,9 +125,9 @@ def process_engine_outputs_seg(
# NMS
detections_output = self.nms_function(
outputs=detections,
nc=nc,
iou_thres=kwargs.get("iou_thres", 0.25),
conf_thres=kwargs.get("conf_thres", 0.45),
nm=nm,
multi_label=kwargs.get("multi_label", False),
)

Expand Down
26 changes: 11 additions & 15 deletions src/deepsparse/yolov8/utils/validation/deepsparse_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@

from deepsparse.yolov8.utils.validation.helpers import schema_to_tensor
from ultralytics.yolo.data.utils import check_det_dataset
from ultralytics.yolo.utils import (
DEFAULT_CFG,
LOGGER,
RANK,
SETTINGS,
TQDM_BAR_FORMAT,
callbacks,
)
from ultralytics.yolo.utils import LOGGER, TQDM_BAR_FORMAT, callbacks
from ultralytics.yolo.utils.ops import Profile
from ultralytics.yolo.utils.torch_utils import select_device, smart_inference_mode

Expand All @@ -42,7 +35,6 @@ def __call__(self, classes: Dict[int, str]):
callbacks.add_integration_callbacks(self)
self.run_callbacks("on_val_start")
self.device = select_device(self.args.device, self.args.batch)
self.args.half &= self.device.type != "cpu"
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 +45,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 +85,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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
logger=None,
args=None,
):
SegmentationValidator.__init__(self, dataloader, save_dir, pbar, logger, args)
SegmentationValidator.__init__(self, dataloader, save_dir, pbar, args)
DeepSparseValidator.__init__(self, pipeline)

# deepsparse edit: replaced argument `model` with `classes`
Expand Down
2 changes: 1 addition & 1 deletion src/deepsparse/yolov8/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
@click.option(
"--subtask",
default="detection",
type=click.Choice(["detection", "classification", "segmentation"]),
type=click.Choice(["detection", "segmentation"]),
show_default=True,
help="A subtask of YOLOv8 to run. Default is `detection`.",
)
Expand Down
Loading