Browse Source

Separate a simple dataflow for CI (without yolo) and a yolo dataflow

arrow_union
Hennzau haixuanTao 1 year ago
parent
commit
aeb11627d6
6 changed files with 52 additions and 45 deletions
  1. +1
    -1
      .github/workflows/ci.yml
  2. +3
    -6
      examples/python-dataflow/README.md
  3. +0
    -15
      examples/python-dataflow/dataflow.yml
  4. +1
    -16
      examples/python-dataflow/dataflow_dynamic.yml
  5. +44
    -0
      examples/python-dataflow/dataflow_yolo.yml
  6. +3
    -7
      examples/python-dataflow/run.rs

+ 1
- 1
.github/workflows/ci.yml View File

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


+ 3
- 6
examples/python-dataflow/README.md View File

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

+ 0
- 15
examples/python-dataflow/dataflow.yml View File

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


+ 1
- 16
examples/python-dataflow/dataflow_dynamic.yml View File

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


+ 44
- 0
examples/python-dataflow/dataflow_yolo.yml View File

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

+ 3
- 7
examples/python-dataflow/run.rs View File

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


Loading…
Cancel
Save