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

update yolov8.py #5345

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Changes from all 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
26 changes: 15 additions & 11 deletions python/ncnn/model_zoo/yolov8.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .model_store import get_model_file
from ..utils.objects import Detect_Object
from ..utils.functional import *
from typing import Iterable

class YoloV8s:
def __init__(
Expand Down Expand Up @@ -204,17 +205,20 @@ def __call__(self, img):
pred, self.prob_threshold, self.nms_threshold
)[0]

objects = [
Detect_Object(
obj[5],
obj[4],
(obj[0] - (wpad / 2)) / scale,
(obj[1] - (hpad / 2)) / scale,
(obj[2] - obj[0]) / scale,
(obj[3] - obj[1]) / scale,
)
for obj in result
]
if isinstance(result, Iterable):
objects = [
Detect_Object(
obj[5],
obj[4],
(obj[0] - (wpad / 2)) / scale,
(obj[1] - (hpad / 2)) / scale,
(obj[2] - obj[0]) / scale,
(obj[3] - obj[1]) / scale,
)
for obj in result
]
else:
objects = []

return objects

Expand Down
Loading