mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:46:30 +00:00
c1b5b5fee2
make inference in batches, fix c# handling, add overlap handling
24 lines
803 B
Cython
24 lines
803 B
Cython
import msgpack
|
|
|
|
cdef class RemoteCommand:
|
|
def __init__(self, CommandType command_type, str filename, bytes data):
|
|
self.command_type = command_type
|
|
self.filename = filename
|
|
self.data = data
|
|
|
|
def __str__(self):
|
|
command_type_names = {
|
|
10: "GET_USER",
|
|
20: "LOAD",
|
|
30: "INFERENCE",
|
|
40: "STOP_INFERENCE",
|
|
100: "EXIT"
|
|
}
|
|
data_str = f'. Data: {len(self.data)} bytes' if self.data else ''
|
|
return f'{command_type_names[self.command_type]}: {self.filename}{data_str}'
|
|
|
|
@staticmethod
|
|
cdef from_msgpack(bytes data):
|
|
unpacked = msgpack.unpackb(data, strict_map_key=False)
|
|
return RemoteCommand(unpacked.get("CommandType"), unpacked.get("Filename"), unpacked.get("Data"))
|