From 242513fd72874b45bea0ceeb5184642f1645cf41 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 24 Oct 2023 14:58:14 +0200 Subject: [PATCH] Start fixing Python dataflow example --- examples/python-dataflow/object_detection.py | 2 +- examples/python-dataflow/plot.py | 6 +++--- examples/python-operator-dataflow/plot.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/python-dataflow/object_detection.py b/examples/python-dataflow/object_detection.py index 7209c2ea..e74feadd 100755 --- a/examples/python-dataflow/object_detection.py +++ b/examples/python-dataflow/object_detection.py @@ -18,7 +18,7 @@ for event in node: match event["id"]: case "image": print("[object detection] received image input") - frame = np.frombuffer(event["data"], dtype="uint8") + frame = event["value"].to_numpy() frame = cv2.imdecode(frame, -1) frame = frame[:, :, ::-1] # OpenCV image (BGR to RGB) results = model(frame) # includes NMS diff --git a/examples/python-dataflow/plot.py b/examples/python-dataflow/plot.py index 5d0c6c01..7284a6d7 100755 --- a/examples/python-dataflow/plot.py +++ b/examples/python-dataflow/plot.py @@ -33,15 +33,15 @@ class Plotter: Args: dora_input["id"] (str): Id of the dora_input declared in the yaml configuration - dora_input["data"] (bytes): Bytes message of the dora_input + dora_input["value"] (arrow array): message of the dora_input """ if dora_input["id"] == "image": - frame = np.frombuffer(dora_input["data"], dtype="uint8") + frame = dora_input["value"].to_numpy() frame = cv2.imdecode(frame, -1) self.image = frame elif dora_input["id"] == "bbox" and len(self.image) != 0: - bboxs = np.frombuffer(dora_input["data"], dtype="float32") + bboxs = dora_input["value"].to_numpy() self.bboxs = np.reshape(bboxs, (-1, 6)) for bbox in self.bboxs: [ diff --git a/examples/python-operator-dataflow/plot.py b/examples/python-operator-dataflow/plot.py index 948b8086..e7c32f29 100755 --- a/examples/python-operator-dataflow/plot.py +++ b/examples/python-operator-dataflow/plot.py @@ -50,7 +50,7 @@ class Operator: Args: dora_input["id"] (str): Id of the dora_input declared in the yaml configuration - dora_input["data"] (bytes): Bytes message of the dora_input + dora_input["value"] (arrow array): message of the dora_input send_output Callable[[str, bytes | pa.UInt8Array, Optional[dict]], None]: Function for sending output to the dataflow: - First argument is the `output_id`