-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsimple_example.py
More file actions
52 lines (45 loc) · 1.35 KB
/
simple_example.py
File metadata and controls
52 lines (45 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
from adora import build, run
from adora.builder import DataflowBuilder
# Get the directory of the current script
script_dir = os.path.dirname(os.path.abspath(__file__))
# Initialize a new dataflow
dataflow = DataflowBuilder(name="yolo-dataflow")
# Define the nodes
camera = dataflow.add_node(
id="camera",
path="opencv-video-capture",
build="pip install opencv-video-capture",
env={
"CAPTURE_PATH": "0",
"IMAGE_WIDTH": "640",
"IMAGE_HEIGHT": "480",
},
)
camera.add_input("tick", "adora/timer/millis/20")
camera_image = camera.add_output("image")
object_detection = dataflow.add_node(
id="object-detection",
path="adora-yolo",
build="pip install adora-yolo",
)
object_detection.add_input("image", camera_image)
bbox_output = object_detection.add_output("bbox")
plot = dataflow.add_node(
id="plot",
path="opencv-plot",
build="pip install opencv-plot",
)
# Connect the nodes using outputs
plot.add_input("image", camera_image)
plot.add_input("boxes2d", bbox_output)
# Generate the YAML file
dataflow.to_yaml("dataflow.yml")
print("Generated dataflow.yml")
# If env var NO_BUILD is set, skip the build and run steps
if not os.getenv("NO_BUILD"):
build("dataflow.yml", uv=True)
else:
print("Skipping build due to NO_BUILD env var")
print("Running dataflow.yml")
run("dataflow.yml", uv=True)