vision-agent 0.2.238__tar.gz → 0.2.239__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {vision_agent-0.2.238 → vision_agent-0.2.239}/PKG-INFO +1 -1
  2. {vision_agent-0.2.238 → vision_agent-0.2.239}/pyproject.toml +1 -1
  3. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/tools/tools.py +1 -1
  4. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/video.py +13 -38
  5. {vision_agent-0.2.238 → vision_agent-0.2.239}/LICENSE +0 -0
  6. {vision_agent-0.2.238 → vision_agent-0.2.239}/README.md +0 -0
  7. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/.sim_tools/df.csv +0 -0
  8. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/.sim_tools/embs.npy +0 -0
  9. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/__init__.py +0 -0
  10. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/README.md +0 -0
  11. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/__init__.py +0 -0
  12. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/agent.py +0 -0
  13. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent.py +0 -0
  14. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_coder.py +0 -0
  15. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_coder_prompts.py +0 -0
  16. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_coder_prompts_v2.py +0 -0
  17. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_coder_v2.py +0 -0
  18. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_planner.py +0 -0
  19. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_planner_prompts.py +0 -0
  20. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_planner_prompts_v2.py +0 -0
  21. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_planner_v2.py +0 -0
  22. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_prompts.py +0 -0
  23. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_prompts_v2.py +0 -0
  24. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/agent/vision_agent_v2.py +0 -0
  25. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/clients/__init__.py +0 -0
  26. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/clients/http.py +0 -0
  27. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/clients/landing_public_api.py +0 -0
  28. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/configs/__init__.py +0 -0
  29. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/configs/anthropic_config.py +0 -0
  30. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/configs/anthropic_openai_config.py +0 -0
  31. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/configs/config.py +0 -0
  32. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/configs/openai_config.py +0 -0
  33. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/fonts/__init__.py +0 -0
  34. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
  35. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/lmm/__init__.py +0 -0
  36. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/lmm/lmm.py +0 -0
  37. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/models/__init__.py +0 -0
  38. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/models/agent_types.py +0 -0
  39. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/models/lmm_types.py +0 -0
  40. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/models/tools_types.py +0 -0
  41. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/sim/__init__.py +0 -0
  42. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/sim/sim.py +0 -0
  43. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/tools/__init__.py +0 -0
  44. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/tools/meta_tools.py +0 -0
  45. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/tools/planner_tools.py +0 -0
  46. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/tools/prompts.py +0 -0
  47. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/__init__.py +0 -0
  48. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/agent.py +0 -0
  49. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/exceptions.py +0 -0
  50. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/execute.py +0 -0
  51. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/image_utils.py +0 -0
  52. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/tools.py +0 -0
  53. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/tools_doc.py +0 -0
  54. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/type_defs.py +0 -0
  55. {vision_agent-0.2.238 → vision_agent-0.2.239}/vision_agent/utils/video_tracking.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vision-agent
3
- Version: 0.2.238
3
+ Version: 0.2.239
4
4
  Summary: Toolset for Vision Agent
5
5
  Author: Landing AI
6
6
  Author-email: dev@landing.ai
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "vision-agent"
7
- version = "0.2.238"
7
+ version = "0.2.239"
8
8
  description = "Toolset for Vision Agent"
9
9
  authors = ["Landing AI <dev@landing.ai>"]
10
10
  readme = "README.md"
@@ -2804,7 +2804,7 @@ def save_video(
2804
2804
  else:
2805
2805
  Path(output_video_path).parent.mkdir(parents=True, exist_ok=True)
2806
2806
 
2807
- output_video_path = video_writer(frames, fps, output_video_path)
2807
+ output_video_path = video_writer(frames, fps, filename=output_video_path)
2808
2808
  _save_video_to_result(output_video_path)
2809
2809
  return output_video_path
2810
2810
 
@@ -1,5 +1,5 @@
1
- import base64
2
1
  import logging
2
+ import os
3
3
  import tempfile
4
4
  from functools import lru_cache
5
5
  from typing import List, Optional, Tuple
@@ -15,37 +15,6 @@ _DEFAULT_VIDEO_FPS = 24
15
15
  _DEFAULT_INPUT_FPS = 1.0
16
16
 
17
17
 
18
- def play_video(video_base64: str) -> None:
19
- """Play a video file"""
20
- video_data = base64.b64decode(video_base64)
21
- with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as temp_video:
22
- temp_video.write(video_data)
23
- temp_video_path = temp_video.name
24
-
25
- cap = cv2.VideoCapture(temp_video_path)
26
- if not cap.isOpened():
27
- _LOGGER.error("Error: Could not open video.")
28
- return
29
-
30
- # Display the first frame and wait for any key press to start the video
31
- ret, frame = cap.read()
32
- if ret:
33
- cv2.imshow("Video Player", frame)
34
- _LOGGER.info(f"Press any key to start playing the video: {temp_video_path}")
35
- cv2.waitKey(0) # Wait for any key press
36
-
37
- while cap.isOpened():
38
- ret, frame = cap.read()
39
- if not ret:
40
- break
41
- cv2.imshow("Video Player", frame)
42
- # Press 'q' to exit the video
43
- if cv2.waitKey(200) & 0xFF == ord("q"):
44
- break
45
- cap.release()
46
- cv2.destroyAllWindows()
47
-
48
-
49
18
  def _resize_frame(frame: np.ndarray) -> np.ndarray:
50
19
  height, width = frame.shape[:2]
51
20
  new_width = width - (width % 2)
@@ -57,12 +26,15 @@ def video_writer(
57
26
  frames: List[np.ndarray],
58
27
  fps: float = _DEFAULT_INPUT_FPS,
59
28
  filename: Optional[str] = None,
29
+ file_ext: str = ".mp4",
60
30
  ) -> str:
31
+ tempf = None
61
32
  if isinstance(fps, str):
62
33
  # fps could be a string when it's passed in from a web endpoint deployment
63
34
  fps = float(fps)
64
35
  if filename is None:
65
- filename = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4").name
36
+ tempf = tempfile.NamedTemporaryFile(delete=False, suffix=file_ext)
37
+ filename = tempf.name
66
38
  container = av.open(filename, mode="w")
67
39
  stream = container.add_stream("h264", rate=fps)
68
40
  height, width = frames[0].shape[:2]
@@ -82,6 +54,9 @@ def video_writer(
82
54
  for packet in stream.encode():
83
55
  container.mux(packet)
84
56
  container.close()
57
+ # for windows nee to manually close tempfile, cannot use with NamedTemporaryFile(delete=True)
58
+ if tempf is not None:
59
+ tempf.close()
85
60
  return filename
86
61
 
87
62
 
@@ -98,11 +73,11 @@ def frames_to_bytes(
98
73
  if isinstance(fps, str):
99
74
  # fps could be a string when it's passed in from a web endpoint deployment
100
75
  fps = float(fps)
101
- with tempfile.NamedTemporaryFile(delete=True, suffix=file_ext) as temp_file:
102
- video_writer(frames, fps, temp_file.name)
103
-
104
- with open(temp_file.name, "rb") as f:
105
- buffer_bytes = f.read()
76
+ filename = video_writer(frames, fps, file_ext=file_ext)
77
+ # TODO: look into memory-mapped files to avoid reading the entire file into memory
78
+ with open(filename, "rb") as f:
79
+ buffer_bytes = f.read()
80
+ os.unlink(filename)
106
81
  return buffer_bytes
107
82
 
108
83
 
File without changes
File without changes