diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71501d15..200b3b17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -321,7 +321,7 @@ jobs: dora stop --name ci-python-test --grace-duration 5s dora build ../examples/python-dataflow/dataflow_dynamic.yml dora start ../examples/python-dataflow/dataflow_dynamic.yml --name ci-python-dynamic --detach - ultralytics-yolo --name object-detection + opencv-plot --name plot sleep 5 dora stop --name ci-python-dynamic --grace-duration 5s dora destroy diff --git a/examples/python-dataflow/README.md b/examples/python-dataflow/README.md index 8e2c75ec..aa0c9be0 100644 --- a/examples/python-dataflow/README.md +++ b/examples/python-dataflow/README.md @@ -7,13 +7,10 @@ This examples shows how to create and connect dora nodes in Python. The [`dataflow.yml`](./dataflow.yml) defines a simple dataflow graph with the following three nodes: - a webcam node, that connects to your webcam and feed the dataflow with webcam frame as jpeg compressed bytearray. -- an object detection node, that apply Yolo v5 on the webcam image. The model is imported from Pytorch Hub. The output - is the bounding box of each object detected, the confidence and the associated label. You can have more info - here: https://pytorch.org/hub/ultralytics_yolov5/ -- a window plotting node, that will retrieve the webcam image and the Yolov5 bounding box and join the two together. +- a window plotting node, that will retrieve the webcam image and plot it. The same dataflow is implemented for a `dynamic-node` in [`dataflow_dynamic.yml`](./dataflow_dynamic.yml). It contains -the same nodes as the previous dataflow, but the object detection node is a dynamic node. See the next section for more +the same nodes as the previous dataflow, but the plot node is a dynamic node. See the next section for more information on how to start such a dataflow. ## Getting started @@ -40,5 +37,5 @@ dora start ./dataflow.yml (or dora start ./dataflow_dynamic.yml) ```bash # activate your virtual environment in another terminal -python ultralytics-yolo --name object-detection --model yolov5n.pt +python opencv-plot --name plot ``` \ No newline at end of file diff --git a/examples/python-dataflow/dataflow.yml b/examples/python-dataflow/dataflow.yml index 23562fed..09015863 100644 --- a/examples/python-dataflow/dataflow.yml +++ b/examples/python-dataflow/dataflow.yml @@ -13,19 +13,6 @@ nodes: IMAGE_WIDTH: 640 IMAGE_HEIGHT: 480 - - id: object-detection - build: pip install ../../node-hub/ultralytics-yolo - path: ultralytics-yolo - inputs: - image: - source: camera/image - queue_size: 1 - - outputs: - - bbox - env: - MODEL: yolov5n.pt - - id: plot build: pip install ../../node-hub/opencv-plot path: opencv-plot @@ -34,8 +21,6 @@ nodes: source: camera/image queue_size: 1 - bbox: object-detection/bbox - tick: source: dora/timer/millis/16 # this node display a window, so it's better to deflect the timer, so when the window is closed, the ticks are not sent anymore in the graph queue_size: 1 diff --git a/examples/python-dataflow/dataflow_dynamic.yml b/examples/python-dataflow/dataflow_dynamic.yml index 140cd6c8..b949d0a4 100644 --- a/examples/python-dataflow/dataflow_dynamic.yml +++ b/examples/python-dataflow/dataflow_dynamic.yml @@ -13,29 +13,14 @@ nodes: IMAGE_WIDTH: 640 IMAGE_HEIGHT: 480 - - id: object-detection - build: pip install ../../node-hub/ultralytics-yolo - path: dynamic - inputs: - image: - source: camera/image - queue_size: 1 - - outputs: - - bbox - env: - MODEL: yolov5n.pt - - id: plot build: pip install ../../node-hub/opencv-plot - path: opencv-plot + path: dynamic inputs: image: source: camera/image queue_size: 1 - bbox: object-detection/bbox - tick: source: dora/timer/millis/16 # this node display a window, so it's better to deflect the timer, so when the window is closed, the ticks are not sent anymore in the graph queue_size: 1 diff --git a/examples/python-dataflow/dataflow_yolo.yml b/examples/python-dataflow/dataflow_yolo.yml new file mode 100644 index 00000000..23562fed --- /dev/null +++ b/examples/python-dataflow/dataflow_yolo.yml @@ -0,0 +1,44 @@ +nodes: + - id: camera + build: pip install ../../node-hub/opencv-video-capture + path: opencv-video-capture + inputs: + tick: plot/tick + + outputs: + - image + + env: + CAPTURE_PATH: 0 + IMAGE_WIDTH: 640 + IMAGE_HEIGHT: 480 + + - id: object-detection + build: pip install ../../node-hub/ultralytics-yolo + path: ultralytics-yolo + inputs: + image: + source: camera/image + queue_size: 1 + + outputs: + - bbox + env: + MODEL: yolov5n.pt + + - id: plot + build: pip install ../../node-hub/opencv-plot + path: opencv-plot + inputs: + image: + source: camera/image + queue_size: 1 + + bbox: object-detection/bbox + + tick: + source: dora/timer/millis/16 # this node display a window, so it's better to deflect the timer, so when the window is closed, the ticks are not sent anymore in the graph + queue_size: 1 + + outputs: + - tick \ No newline at end of file diff --git a/examples/python-dataflow/run.rs b/examples/python-dataflow/run.rs index 25d0f870..1271776b 100644 --- a/examples/python-dataflow/run.rs +++ b/examples/python-dataflow/run.rs @@ -50,13 +50,9 @@ async fn main() -> eyre::Result<()> { ); } - run( - "pip", - &["install", "maturin"], - Some (venv), - ) - .await - .context("pip install maturin failed")?; + run("pip", &["install", "maturin"], Some(venv)) + .await + .context("pip install maturin failed")?; run( "maturin",