Skip to content

Commit

Permalink
openvino: functional yolov8
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Jun 15, 2023
1 parent ef742bd commit 74cd23b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions plugins/openvino/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/openvino/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.29"
"version": "0.1.30"
}
18 changes: 9 additions & 9 deletions plugins/openvino/src/ov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import numpy as np
import yolo


def parse_label_contents(contents: str):
lines = contents.splitlines()
ret = {}
Expand Down Expand Up @@ -126,7 +125,7 @@ async def getSettings(self) -> list[Setting]:
'ssdlite_mobilenet_v2',
'yolo-v3-tiny-tf',
'yolo-v4-tiny-tf',
# 'yolov8n',
'yolov8n',
],
'value': model,
},
Expand Down Expand Up @@ -171,10 +170,12 @@ async def detect_once(self, input: Image.Image, settings: Any, src_size, cvss):
def predict():
infer_request = self.compiled_model.create_infer_request()
if self.yolov8:
i = np.array(input)
c = np.squeeze(np.split(i, i.shape[-1], -1), axis=-1)
d = np.expand_dims(c, axis=0)
input_tensor = ov.Tensor(array=d.astype(np.float32), shared_memory=True)
im = np.stack([input])
im = im.transpose((0, 3, 1, 2)) # BHWC to BCHW, (n, 3, h, w)
im = im.astype(np.float32) / 255.0
im = np.ascontiguousarray(im) # contiguous
im = ov.Tensor(array=im, shared_memory=True)
input_tensor = im
elif self.yolo:
input_tensor = ov.Tensor(array=np.expand_dims(np.array(input), axis=0).astype(np.float32), shared_memory=True)
else:
Expand All @@ -187,9 +188,8 @@ def predict():
objs = []

if self.yolov8:
objs = yolo.parse_yolov8(infer_request.outputs[0].data)
ret = self.create_detection_result(objs, src_size, cvss)
return ret
objs = yolo.parse_yolov8(infer_request.outputs[0].data[0])
return objs

if self.yolo:
# index 2 will always either be 13 or 26
Expand Down

0 comments on commit 74cd23b

Please sign in to comment.