mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 19:26:31 +00:00
add ramdisk, load AI model to ramdisk and start recognition from it
rewrite zmq to DEALER and ROUTER add GET_USER command to get CurrentUser from Python all auth is on the python side inference run and validate annotations on python
This commit is contained in:
@@ -1,13 +1,35 @@
|
||||
import msgpack
|
||||
|
||||
cdef class Detection:
|
||||
def __init__(self, double x, double y, double w, double h, int cls):
|
||||
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, bytes image_bytes, float time, list[Detection] detections):
|
||||
def __init__(self, bytes image_bytes, long time, list[Detection] detections):
|
||||
self.image = image_bytes
|
||||
self.time = time
|
||||
self.detections = detections
|
||||
self.detections = detections if detections is not None else []
|
||||
|
||||
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
|
||||
]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user