Skip to content

Commit b5612a6

Browse files
committed
Update to run hailo demos
1 parent 20543b6 commit b5612a6

4 files changed

Lines changed: 8 additions & 20 deletions

File tree

abraia/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from dotenv import load_dotenv
33
load_dotenv()
44

5-
__version__ = '0.26.0'
5+
__version__ = '0.26.1'
66

77
from . import config
88
from .client import Abraia, APIError

abraia/demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
DEMOS = {
1717
'apple': {
18+
'model': 'multiple/models/yolov8n-seg.onnx',
1819
'src': '5479199-hd_1920_1080_25fps.mp4',
1920
'labels': ['apple']
2021
},

abraia/hailo/toolbox.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,44 +1321,32 @@ def _get_results(self, bindings):
13211321
# mh, mw, _ = self.get_input_shape()
13221322
# detections = []
13231323
# for det in infer_results:
1324-
# print(det)
13251324
# if det.score < self.score_threshold: break
13261325
# xmin, ymin, xmax, ymax = map_box_to_orig([det.x_min * mw, det.y_min * mh, det.x_max * mw, det.y_max * mh], (oh, ow), (mh, mw))
13271326
# detection = {'label': self.labels[det.class_id] if self.labels else str(det.class_id), 'score': float(det.score), 'box': [xmin, ymin, xmax - xmin, ymax - ymin], 'class_id': det.class_id}
13281327
# if self.task == 'segment':
13291328
# mask = resize_mask_to_unpadded_box(det.mask, [xmin, ymin, xmax, ymax], [det.x_min * mw, det.y_min * mh, det.x_max * mw, det.y_max * mh])
13301329
# if mask is not None: detection['mask'] = mask
13311330
# detections.append(detection)
1332-
# print(detections)
13331331
# return detections
13341332

13351333
def _process_nms_results(self, result, image):
13361334
infer_results = result if isinstance(result, list) else [result]
13371335
img_height, img_width = image.shape[:2]
13381336
size = max(img_height, img_width)
13391337
padding_length = int(abs(img_height - img_width) / 2)
1340-
13411338
detections = []
13421339
for det in infer_results:
1343-
if det.score < self.score_threshold:
1344-
break
1345-
1340+
if det.score < self.score_threshold: break
13461341
box_on_input_image, box_on_padded_image = convert_box_from_normalized(
13471342
[det.x_min, det.y_min, det.x_max, det.y_max], size, padding_length, img_height, img_width)
1348-
13491343
xmin, ymin, xmax, ymax = box_on_input_image
1350-
detection = {
1351-
'label': self.labels[det.class_id] if self.labels else str(det.class_id),
1352-
'score': float(det.score),
1353-
'box': [xmin, ymin, xmax - xmin, ymax - ymin],
1354-
'class_id': det.class_id
1355-
}
1356-
1344+
detection = {'label': self.labels[det.class_id] if self.labels else str(det.class_id),
1345+
'score': float(det.score), 'box': [xmin, ymin, xmax - xmin, ymax - ymin], 'class_id': det.class_id}
13571346
if self.task == 'segment':
13581347
mask = resize_mask_to_unpadded_box(det.mask, box_on_input_image, box_on_padded_image)
13591348
if mask is not None:
13601349
detection['mask'] = mask
1361-
13621350
detections.append(detection)
13631351
return detections
13641352

abraia/inference/ops.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,11 @@ def softmax(x, axis=-1):
237237

238238

239239
def count_objects(results):
240-
counts, colors = {}, {}
240+
counts = {}
241241
for result in results:
242-
label, color = result['label'], result['color']
242+
label= result['label']
243243
counts[label] = counts.get(label, 0) + 1
244-
colors[label] = color
245-
objects = [{'label': label, 'count': counts[label], 'color': colors[label]} for label in counts.keys()]
244+
objects = [{'label': label, 'count': counts[label]} for label in counts.keys()]
246245
return objects
247246

248247

0 commit comments

Comments
 (0)