Browse Source

Start fixing Python dataflow example

tags/v0.3.0-rc
Philipp Oppermann 2 years ago
parent
commit
242513fd72
Failed to extract signature
3 changed files with 5 additions and 5 deletions
  1. +1
    -1
      examples/python-dataflow/object_detection.py
  2. +3
    -3
      examples/python-dataflow/plot.py
  3. +1
    -1
      examples/python-operator-dataflow/plot.py

+ 1
- 1
examples/python-dataflow/object_detection.py View File

@@ -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


+ 3
- 3
examples/python-dataflow/plot.py View File

@@ -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:
[


+ 1
- 1
examples/python-operator-dataflow/plot.py View File

@@ -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`


Loading…
Cancel
Save