haixuantao commited on
Commit
f4392e4
1 Parent(s): c33eefb

Encode image as png

Browse files
Files changed (37) hide show
  1. graphs/dataflow.yml +17 -6
  2. graphs/out/018dfdbb-c6e6-7984-8e3b-6da4f876fbce/whisper_text.arrow +0 -3
  3. graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/audio.parquet +0 -3
  4. graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/mistral_output_file.parquet +0 -3
  5. graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/raw_file.parquet +0 -3
  6. graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/saved_file.parquet +0 -3
  7. graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/whisper_text.parquet +0 -3
  8. graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/audio.parquet +0 -3
  9. graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/image.parquet +0 -0
  10. graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/raw_file.parquet +0 -3
  11. graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/whisper_text.parquet +0 -3
  12. graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/audio.parquet +0 -3
  13. graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/mistral_output_file.parquet +0 -3
  14. graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/raw_file.parquet +0 -3
  15. graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/saved_file.parquet +0 -3
  16. graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/whisper_text.parquet +0 -3
  17. graphs/out/018dfe09-1627-7f91-aeeb-e2b06b68dec8/audio.parquet +0 -3
  18. graphs/out/018dfe09-1627-7f91-aeeb-e2b06b68dec8/raw_file.parquet +0 -3
  19. graphs/out/018dfe09-1627-7f91-aeeb-e2b06b68dec8/whisper_text.parquet +0 -3
  20. graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/audio.parquet +0 -3
  21. graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/mistral_output_file.parquet +0 -3
  22. graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/raw_file.parquet +0 -3
  23. graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/saved_file.parquet +0 -3
  24. graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/whisper_text.parquet +0 -3
  25. graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/audio.parquet +0 -3
  26. graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/mistral_output_file.parquet +0 -3
  27. graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/raw_file.parquet +0 -3
  28. graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/saved_file.parquet +0 -3
  29. graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/whisper_text.parquet +0 -3
  30. graphs/out/{018dfdbb-c6e6-7984-8e3b-6da4f876fbce/audio.arrow → 018dff34-35f1-71b0-b8bc-e4a03a6333ab/image.parquet} +2 -2
  31. graphs/out/{018dfdbb-c6e6-7984-8e3b-6da4f876fbce/raw_file.arrow → 018dff34-e690-798e-8fb4-1b96c1d14763/image.parquet} +2 -2
  32. operators/cv2_encoder_op.py +32 -0
  33. operators/keybinding_op.py +8 -1
  34. operators/object_detection.py +1 -2
  35. operators/planning_op.py +2 -2
  36. operators/plot.py +0 -2
  37. operators/whisper_op.py +1 -1
graphs/dataflow.yml CHANGED
@@ -35,14 +35,10 @@ nodes:
35
  - id: object_detection
36
  operator:
37
  python: ../operators/object_detection.py
38
- send_stdout_as: stdout
39
  inputs:
40
- image:
41
- source: webcam/image
42
- queue_size: 1
43
  outputs:
44
  - bbox
45
- - stdout
46
 
47
  ### Second Camera
48
  - id: webcam
@@ -60,7 +56,7 @@ nodes:
60
  python: ../operators/plot.py
61
  inputs:
62
  image: webcam/image
63
- text: object_detection/stdout
64
  bbox: object_detection/bbox
65
 
66
 
@@ -93,6 +89,11 @@ nodes:
93
  - revert
94
  - failed
95
  - error
 
 
 
 
 
96
 
97
  - id: microphone
98
  operator:
@@ -159,3 +160,13 @@ nodes:
159
  saved_file: file_saver/saved_file
160
  audio: microphone/audio
161
  whisper_text: whisper/text
 
 
 
 
 
 
 
 
 
 
 
35
  - id: object_detection
36
  operator:
37
  python: ../operators/object_detection.py
 
38
  inputs:
39
+ image: webcam/image
 
 
40
  outputs:
41
  - bbox
 
42
 
43
  ### Second Camera
44
  - id: webcam
 
56
  python: ../operators/plot.py
57
  inputs:
58
  image: webcam/image
59
+ text: whisper/text
60
  bbox: object_detection/bbox
61
 
62
 
 
89
  - revert
90
  - failed
91
  - error
92
+ inputs:
93
+ tick:
94
+ source: dora/timer/millis/50
95
+ queue_size: 1
96
+
97
 
98
  - id: microphone
99
  operator:
 
160
  saved_file: file_saver/saved_file
161
  audio: microphone/audio
162
  whisper_text: whisper/text
163
+ image: cv2_encoder/encoded_image
164
+
165
+ ### Second Camera
166
+ - id: cv2_encoder
167
+ operator:
168
+ python: ../operators/cv2_encoder_op.py
169
+ inputs:
170
+ image: webcam/image
171
+ outputs:
172
+ - encoded_image
graphs/out/018dfdbb-c6e6-7984-8e3b-6da4f876fbce/whisper_text.arrow DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c9623efabfbd00d46318455138ef03d76e017f38f222ed875036358942b5a7e
3
- size 816
 
 
 
 
graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/audio.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ae879db0dadd44a5bced6ed5ed76cf7cec4a05fd3bcb1a82a6b21b0838d6eb6
3
- size 799
 
 
 
 
graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/mistral_output_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e507cc5252075922e0be1646a62ef6992b34957deb2bac6b55d61891e051d739
3
- size 1130
 
 
 
 
graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/raw_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d0b80daf802b9fda908b4cafd18f58dddc6659009d24a8e27dc7336b455691e1
3
- size 1025
 
 
 
 
graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/saved_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e20d825d340fdf055fc274297ee74e2c90469173898a4032744ab0f8821f5a4b
3
- size 1028
 
 
 
 
graphs/out/018dfdbd-32c9-7115-96c7-865c223b5963/whisper_text.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c9623efabfbd00d46318455138ef03d76e017f38f222ed875036358942b5a7e
3
- size 816
 
 
 
 
graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/audio.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ae879db0dadd44a5bced6ed5ed76cf7cec4a05fd3bcb1a82a6b21b0838d6eb6
3
- size 799
 
 
 
 
graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/image.parquet DELETED
File without changes
graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/raw_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d0b80daf802b9fda908b4cafd18f58dddc6659009d24a8e27dc7336b455691e1
3
- size 1025
 
 
 
 
graphs/out/018dfdc2-f116-7f77-88de-46e9e79e89a5/whisper_text.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c9623efabfbd00d46318455138ef03d76e017f38f222ed875036358942b5a7e
3
- size 816
 
 
 
 
graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/audio.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ae879db0dadd44a5bced6ed5ed76cf7cec4a05fd3bcb1a82a6b21b0838d6eb6
3
- size 799
 
 
 
 
graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/mistral_output_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e507cc5252075922e0be1646a62ef6992b34957deb2bac6b55d61891e051d739
3
- size 1130
 
 
 
 
graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/raw_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d0b80daf802b9fda908b4cafd18f58dddc6659009d24a8e27dc7336b455691e1
3
- size 1025
 
 
 
 
graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/saved_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e20d825d340fdf055fc274297ee74e2c90469173898a4032744ab0f8821f5a4b
3
- size 1028
 
 
 
 
graphs/out/018dfdca-29a2-77a0-b534-54dc41c23691/whisper_text.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c9623efabfbd00d46318455138ef03d76e017f38f222ed875036358942b5a7e
3
- size 816
 
 
 
 
graphs/out/018dfe09-1627-7f91-aeeb-e2b06b68dec8/audio.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ae879db0dadd44a5bced6ed5ed76cf7cec4a05fd3bcb1a82a6b21b0838d6eb6
3
- size 799
 
 
 
 
graphs/out/018dfe09-1627-7f91-aeeb-e2b06b68dec8/raw_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d0b80daf802b9fda908b4cafd18f58dddc6659009d24a8e27dc7336b455691e1
3
- size 1025
 
 
 
 
graphs/out/018dfe09-1627-7f91-aeeb-e2b06b68dec8/whisper_text.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c9623efabfbd00d46318455138ef03d76e017f38f222ed875036358942b5a7e
3
- size 816
 
 
 
 
graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/audio.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ba1f159da5eef2611d000ea5f633152159606807b1dcf5b3cf5d717dbed89f07
3
- size 69078
 
 
 
 
graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/mistral_output_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:285adb7ced10bb8fae4992162d83593b23a5a94d0699dbb72adf8ab0b7eb21d5
3
- size 25802
 
 
 
 
graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/raw_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ad604d2eedab0dbf0b20fdbb8a275305c1a6c32fe25eb49c8582b90778947e72
3
- size 22324
 
 
 
 
graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/saved_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:73f5cfe5f00e9672a57ed421120eec25ac25c295725964de5e52c3f358669b5b
3
- size 22078
 
 
 
 
graphs/out/018dfe17-8482-7678-995d-7e89b44ceb51/whisper_text.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:59db9f08c5dc7e0da69df5287f57bf5c9a028f67605aece55f1c10b168cc9212
3
- size 2851
 
 
 
 
graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/audio.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:73bf727801eac0741e762b97a9c313642b26d842cd12416d3e0a4beb7d64b35b
3
- size 41262
 
 
 
 
graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/mistral_output_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2b4464eb1b09d75ef9bd3e1a4371c3e266a2615fc6919d6b933993d1f8b2e6e9
3
- size 25995
 
 
 
 
graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/raw_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e9bb52fb3da616bf10f674cdf839dd093db90e88aee57eb7ddf6fbaebffbb83e
3
- size 22212
 
 
 
 
graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/saved_file.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8dcbb81c073a43923ecd845676bf53a27feebc0c01d9cd764801975cad9be8b2
3
- size 22265
 
 
 
 
graphs/out/018dfe2d-7e22-7df2-9ea0-98f1076faef6/whisper_text.parquet DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e38a36b7cabaaf4efd7e579cd450312c1daf6b35f6c2cffb6a95f1c4f36aeeb7
3
- size 2765
 
 
 
 
graphs/out/{018dfdbb-c6e6-7984-8e3b-6da4f876fbce/audio.arrow → 018dff34-35f1-71b0-b8bc-e4a03a6333ab/image.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ae879db0dadd44a5bced6ed5ed76cf7cec4a05fd3bcb1a82a6b21b0838d6eb6
3
- size 799
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b4b1bbbe635cbf1d40b4be3f1cb6cf35b3e6b6aacd684a2646a186eed1c2d80
3
+ size 4570742
graphs/out/{018dfdbb-c6e6-7984-8e3b-6da4f876fbce/raw_file.arrow → 018dff34-e690-798e-8fb4-1b96c1d14763/image.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d0b80daf802b9fda908b4cafd18f58dddc6659009d24a8e27dc7336b455691e1
3
- size 1025
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0fa779836e7686470e7ad5a2fae328518fe289d5218df2a35fb5eaa314975c2
3
+ size 3283843
operators/cv2_encoder_op.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pyarrow as pa
2
+
3
+ from dora import DoraStatus
4
+ import cv2
5
+ import os
6
+
7
+
8
+ CAMERA_WIDTH = 960
9
+ CAMERA_HEIGHT = 540
10
+
11
+ ENCODING = os.getenv("ENCODING", ".jpg")
12
+
13
+
14
+ class Operator:
15
+ """
16
+ Infering object from images
17
+ """
18
+
19
+ def on_event(
20
+ self,
21
+ dora_event,
22
+ send_output,
23
+ ) -> DoraStatus:
24
+ if dora_event["type"] == "INPUT":
25
+ frame = (
26
+ dora_event["value"].to_numpy().reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3))
27
+ )
28
+ retval, buffer = cv2.imencode(ENCODING, frame)
29
+ if retval:
30
+ send_output("encoded_image", pa.array([buffer]), dora_event["metadata"])
31
+
32
+ return DoraStatus.CONTINUE
operators/keybinding_op.py CHANGED
@@ -27,4 +27,11 @@ def on_key_release(key):
27
  pass
28
 
29
 
30
- pynput.keyboard.Listener(on_release=on_key_release).run()
 
 
 
 
 
 
 
 
27
  pass
28
 
29
 
30
+ pynput.keyboard.Listener(on_release=on_key_release).start()
31
+
32
+ while node.next():
33
+ pass
34
+
35
+ import time
36
+
37
+ time.sleep(0.5)
operators/object_detection.py CHANGED
@@ -49,13 +49,12 @@ class Operator:
49
 
50
  frame = dora_input["value"].to_numpy().reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3))
51
  frame = frame[:, :, ::-1] # OpenCV image (BGR to RGB)
52
- results = self.model(frame) # includes NMS
53
  # Process results
54
  boxes = np.array(results[0].boxes.xyxy.cpu())
55
  conf = np.array(results[0].boxes.conf.cpu())
56
  label = np.array(results[0].boxes.cls.cpu())
57
  # concatenate them together
58
  arrays = np.concatenate((boxes, conf[:, None], label[:, None]), axis=1)
59
-
60
  send_output("bbox", pa.array(arrays.ravel()), dora_input["metadata"])
61
  return DoraStatus.CONTINUE
 
49
 
50
  frame = dora_input["value"].to_numpy().reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3))
51
  frame = frame[:, :, ::-1] # OpenCV image (BGR to RGB)
52
+ results = self.model(frame, verbose=False) # includes NMS
53
  # Process results
54
  boxes = np.array(results[0].boxes.xyxy.cpu())
55
  conf = np.array(results[0].boxes.conf.cpu())
56
  label = np.array(results[0].boxes.cls.cpu())
57
  # concatenate them together
58
  arrays = np.concatenate((boxes, conf[:, None], label[:, None]), axis=1)
 
59
  send_output("bbox", pa.array(arrays.ravel()), dora_input["metadata"])
60
  return DoraStatus.CONTINUE
operators/planning_op.py CHANGED
@@ -2,6 +2,7 @@ import numpy as np
2
  import pyarrow as pa
3
  from dora import DoraStatus
4
 
 
5
  X = 0
6
  # left-right: [-1,1]
7
  Y = 0
@@ -74,8 +75,7 @@ class Operator:
74
  direction = np.clip(
75
  np.array(GOAL_OBJECTIVES) - np.array(self.position), -1, 1
76
  )
77
- print("position ", dora_event["value"].to_numpy(), flush=True)
78
- print(direction, flush=True)
79
  if any(abs(direction) > 0.1):
80
  x = direction[0]
81
  y = direction[1]
 
2
  import pyarrow as pa
3
  from dora import DoraStatus
4
 
5
+ # front-back: [-1, 1]
6
  X = 0
7
  # left-right: [-1,1]
8
  Y = 0
 
75
  direction = np.clip(
76
  np.array(GOAL_OBJECTIVES) - np.array(self.position), -1, 1
77
  )
78
+
 
79
  if any(abs(direction) > 0.1):
80
  x = direction[0]
81
  y = direction[1]
operators/plot.py CHANGED
@@ -76,7 +76,6 @@ class Operator:
76
  self.image = frame
77
 
78
  self.image_messages += 1
79
- print("received " + str(self.image_messages) + " images")
80
 
81
  elif dora_input["id"] == "text" and len(self.image) != 0:
82
  self.text_whisper = dora_input["value"][0].as_py()
@@ -85,7 +84,6 @@ class Operator:
85
  self.bboxs = np.reshape(bboxs, (-1, 6))
86
 
87
  self.bounding_box_messages += 1
88
- print("received " + str(self.bounding_box_messages) + " bounding boxes")
89
 
90
  for bbox in self.bboxs:
91
  [
 
76
  self.image = frame
77
 
78
  self.image_messages += 1
 
79
 
80
  elif dora_input["id"] == "text" and len(self.image) != 0:
81
  self.text_whisper = dora_input["value"][0].as_py()
 
84
  self.bboxs = np.reshape(bboxs, (-1, 6))
85
 
86
  self.bounding_box_messages += 1
 
87
 
88
  for bbox in self.bboxs:
89
  [
operators/whisper_op.py CHANGED
@@ -36,6 +36,6 @@ class Operator:
36
  result = model.transcribe(audio, language="en")
37
  text = result["text"]
38
  print(text, flush=True)
39
- text = "Can you change the bounding box to purple?"
40
  send_output("text", pa.array([text]), dora_event["metadata"])
41
  return DoraStatus.CONTINUE
 
36
  result = model.transcribe(audio, language="en")
37
  text = result["text"]
38
  print(text, flush=True)
39
+ text = "Can you set the RGB to blue?"
40
  send_output("text", pa.array([text]), dora_event["metadata"])
41
  return DoraStatus.CONTINUE