From 9133406c1808e318a359382b82e938d15b3ee599 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Sun, 13 Oct 2024 07:20:30 +0200 Subject: [PATCH] Add `README` section for rerun within the dataflow --- examples/camera/dataflow_rerun.yml | 27 +++++++++++++++++++ examples/vlm/dataflow_rerun.yml | 43 ++++++++++++++++++++++++++++++ node-hub/dora-rerun/src/main.rs | 14 ++++++++++ 3 files changed, 84 insertions(+) create mode 100644 examples/camera/dataflow_rerun.yml create mode 100644 examples/vlm/dataflow_rerun.yml diff --git a/examples/camera/dataflow_rerun.yml b/examples/camera/dataflow_rerun.yml new file mode 100644 index 000000000..2633ec944 --- /dev/null +++ b/examples/camera/dataflow_rerun.yml @@ -0,0 +1,27 @@ +nodes: + - id: camera + build: pip install ../../node-hub/opencv-video-capture + path: opencv-video-capture + inputs: + tick: dora/timer/millis/20 + outputs: + - image + env: + CAPTURE_PATH: 0 + IMAGE_WIDTH: 640 + IMAGE_HEIGHT: 480 + + - id: plot + build: cargo build -p dora-rerun --release + path: dora-rerun + inputs: + image: + source: camera/image + queue_size: 1 + env: + IMAGE_WIDTH: 640 + IMAGE_HEIGHT: 480 + README: | + # Visualization of your webcam + + - You can increase or decrease the frequency within the dataflow with: `tick: dora/timer/millis/20` in the webcam node. \ No newline at end of file diff --git a/examples/vlm/dataflow_rerun.yml b/examples/vlm/dataflow_rerun.yml new file mode 100644 index 000000000..785779e23 --- /dev/null +++ b/examples/vlm/dataflow_rerun.yml @@ -0,0 +1,43 @@ +nodes: + - id: camera + build: pip install -e ../../node-hub/opencv-video-capture + path: opencv-video-capture + inputs: + tick: dora/timer/millis/20 + outputs: + - image + env: + CAPTURE_PATH: 0 + IMAGE_WIDTH: 640 + IMAGE_HEIGHT: 480 + + - id: dora-qwenvl + build: pip install -e ../../node-hub/dora-qwenvl + path: dora-qwenvl + inputs: + image: + source: camera/image + queue_size: 1 + tick: dora/timer/millis/200 + outputs: + - text + - tick + env: + DEFAULT_QUESTION: Describe the image. + + - id: plot + build: cargo build -p dora-rerun --release + path: dora-rerun + inputs: + image: + source: camera/image + queue_size: 1 + text: dora-qwenvl/tick + env: + IMAGE_WIDTH: 640 + IMAGE_HEIGHT: 480 + README: | + # Visualization of your webcam + + - You can increase or decrease the frequency within the dataflow with: `tick: dora/timer/millis/20` in the webcam node. + - You can change the model prompt within the dataflow with: `DEFAULT_QUESTION: Describe the image.` diff --git a/node-hub/dora-rerun/src/main.rs b/node-hub/dora-rerun/src/main.rs index 23b85cc14..c0c2cc048 100644 --- a/node-hub/dora-rerun/src/main.rs +++ b/node-hub/dora-rerun/src/main.rs @@ -43,6 +43,20 @@ fn main() -> Result<()> { .spawn_opts(&options, None) .context("Could not spawn rerun visualization")?; + match std::env::var("README") { + Ok(readme) => { + readme + .parse::() + .context("Could not parse readme value")?; + rec.log("README", &rerun::TextDocument::new(readme)) + .wrap_err("Could not log text")?; + } + Err(VarError::NotUnicode(_)) => { + return Err(eyre!("readme env variable is not unicode")); + } + Err(VarError::NotPresent) => (), + }; + while let Some(event) = events.recv() { if let Event::Input { id, data, metadata } = event { if id.as_str().contains("image") {