move python inference to Azaion.Inference folder

This commit is contained in:
Alex Bezdieniezhnykh
2025-02-06 10:48:03 +02:00
parent 739759628a
commit ba3e3b4a55
39 changed files with 313 additions and 173 deletions
+35
View File
@@ -0,0 +1,35 @@
import msgpack
cdef class Detection:
def __init__(self, double x, double y, double w, double h, int cls, double confidence):
self.x = x
self.y = y
self.w = w
self.h = h
self.cls = cls
self.confidence = confidence
def __str__(self):
return f'{self.cls}: {self.x:.2f} {self.y:.2f} {self.w:.2f} {self.h:.2f}, prob: {(self.confidence*100):.1f}%'
cdef class Annotation:
def __init__(self, long time, list[Detection] detections):
self.time = time
self.detections = detections if detections is not None else []
self.image = b''
cdef bytes serialize(self):
return msgpack.packb({
"i": self.image, # "i" = image
"t": self.time, # "t" = time
"d": [ # "d" = detections
{
"x": det.x,
"y": det.y,
"w": det.w,
"h": det.h,
"c": det.cls,
"p": det.confidence
} for det in self.detections
]
})