rtsm 0.1.0__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 (112) hide show
  1. rtsm-0.1.0/LICENSE +202 -0
  2. rtsm-0.1.0/PKG-INFO +473 -0
  3. rtsm-0.1.0/README.md +431 -0
  4. rtsm-0.1.0/pyproject.toml +73 -0
  5. rtsm-0.1.0/rtsm/__init__.py +0 -0
  6. rtsm-0.1.0/rtsm/__main__.py +13 -0
  7. rtsm-0.1.0/rtsm/analytics/__init__.py +20 -0
  8. rtsm-0.1.0/rtsm/analytics/latency_analytics.py +379 -0
  9. rtsm-0.1.0/rtsm/analytics/seg_analytics.py +189 -0
  10. rtsm-0.1.0/rtsm/api/__init__.py +0 -0
  11. rtsm-0.1.0/rtsm/api/server.py +749 -0
  12. rtsm-0.1.0/rtsm/cfg/__init__.py +68 -0
  13. rtsm-0.1.0/rtsm/cfg/clip/vocab.yaml +495 -0
  14. rtsm-0.1.0/rtsm/cfg/demo_config.yaml +258 -0
  15. rtsm-0.1.0/rtsm/cfg/rtsm.yaml +337 -0
  16. rtsm-0.1.0/rtsm/core/__init__.py +0 -0
  17. rtsm-0.1.0/rtsm/core/association.py +333 -0
  18. rtsm-0.1.0/rtsm/core/datamodel.py +165 -0
  19. rtsm-0.1.0/rtsm/core/ingest_gate.py +136 -0
  20. rtsm-0.1.0/rtsm/core/pipeline.py +886 -0
  21. rtsm-0.1.0/rtsm/core/tasks.py +84 -0
  22. rtsm-0.1.0/rtsm/data/__init__.py +0 -0
  23. rtsm-0.1.0/rtsm/data/demo_clip/index.jsonl +50 -0
  24. rtsm-0.1.0/rtsm/data/demo_clip/messages.bin +0 -0
  25. rtsm-0.1.0/rtsm/data/demo_clip/meta.json +23 -0
  26. rtsm-0.1.0/rtsm/demo.py +310 -0
  27. rtsm-0.1.0/rtsm/io/__init__.py +0 -0
  28. rtsm-0.1.0/rtsm/io/ingest_queue.py +34 -0
  29. rtsm-0.1.0/rtsm/io/mcp_embedded.py +359 -0
  30. rtsm-0.1.0/rtsm/io/mcp_server.py +227 -0
  31. rtsm-0.1.0/rtsm/io/orbslam_zmq_bridge/tools/pub_rgbd.py +83 -0
  32. rtsm-0.1.0/rtsm/io/orbslam_zmq_bridge/tools/sub_debug.py +50 -0
  33. rtsm-0.1.0/rtsm/io/recorder.py +140 -0
  34. rtsm-0.1.0/rtsm/io/replayer.py +221 -0
  35. rtsm-0.1.0/rtsm/io/sensors.py +79 -0
  36. rtsm-0.1.0/rtsm/io/slam.py +25 -0
  37. rtsm-0.1.0/rtsm/io/websocket.py +692 -0
  38. rtsm-0.1.0/rtsm/io/zeromq.py +584 -0
  39. rtsm-0.1.0/rtsm/models/__init__.py +0 -0
  40. rtsm-0.1.0/rtsm/models/clip/__init__.py +0 -0
  41. rtsm-0.1.0/rtsm/models/clip/adapter.py +39 -0
  42. rtsm-0.1.0/rtsm/models/clip/inference.py +77 -0
  43. rtsm-0.1.0/rtsm/models/clip/loader.py +28 -0
  44. rtsm-0.1.0/rtsm/models/clip/preprocess.py +1 -0
  45. rtsm-0.1.0/rtsm/models/clip/vocab_classifier.py +187 -0
  46. rtsm-0.1.0/rtsm/models/segmentation/__init__.py +178 -0
  47. rtsm-0.1.0/rtsm/models/segmentation/base.py +152 -0
  48. rtsm-0.1.0/rtsm/models/segmentation/dual_segmenter.py +314 -0
  49. rtsm-0.1.0/rtsm/models/segmentation/fastsam_segmenter.py +179 -0
  50. rtsm-0.1.0/rtsm/models/segmentation/grounded_sam2_segmenter.py +244 -0
  51. rtsm-0.1.0/rtsm/models/segmentation/sam2_segmenter.py +185 -0
  52. rtsm-0.1.0/rtsm/models/segmentation/yoloe_segmenter.py +235 -0
  53. rtsm-0.1.0/rtsm/run.py +409 -0
  54. rtsm-0.1.0/rtsm/static/assets/index-D1GxaB_c.css +1 -0
  55. rtsm-0.1.0/rtsm/static/assets/index-DP70BXmG.js +3713 -0
  56. rtsm-0.1.0/rtsm/static/index.html +851 -0
  57. rtsm-0.1.0/rtsm/stores/__init__.py +0 -0
  58. rtsm-0.1.0/rtsm/stores/frame_window.py +167 -0
  59. rtsm-0.1.0/rtsm/stores/proximity_index.py +325 -0
  60. rtsm-0.1.0/rtsm/stores/sweep_cache.py +238 -0
  61. rtsm-0.1.0/rtsm/stores/sweep_policy.py +225 -0
  62. rtsm-0.1.0/rtsm/stores/vectors/__init__.py +0 -0
  63. rtsm-0.1.0/rtsm/stores/vectors/faiss_client.py +181 -0
  64. rtsm-0.1.0/rtsm/stores/vectors/milvus_client.py +0 -0
  65. rtsm-0.1.0/rtsm/stores/working_memory.py +801 -0
  66. rtsm-0.1.0/rtsm/utils/__init__.py +0 -0
  67. rtsm-0.1.0/rtsm/utils/browser.py +42 -0
  68. rtsm-0.1.0/rtsm/utils/convert_to_npy.py +18 -0
  69. rtsm-0.1.0/rtsm/utils/load_depth_png_as_meters.py +25 -0
  70. rtsm-0.1.0/rtsm/utils/mask_staging.py +363 -0
  71. rtsm-0.1.0/rtsm/utils/net.py +59 -0
  72. rtsm-0.1.0/rtsm/utils/ocr_helpers.py +0 -0
  73. rtsm-0.1.0/rtsm/utils/periodic_logger.py +101 -0
  74. rtsm-0.1.0/rtsm/utils/prepare_ann.py +30 -0
  75. rtsm-0.1.0/rtsm/utils/transforms.py +273 -0
  76. rtsm-0.1.0/rtsm/visualization/__init__.py +15 -0
  77. rtsm-0.1.0/rtsm/visualization/broadcaster.py +291 -0
  78. rtsm-0.1.0/rtsm/visualization/processor.py +230 -0
  79. rtsm-0.1.0/rtsm/visualization/registry.py +135 -0
  80. rtsm-0.1.0/rtsm/visualization/server.py +922 -0
  81. rtsm-0.1.0/rtsm/visualization/tsdf_integrator.py +329 -0
  82. rtsm-0.1.0/rtsm.egg-info/PKG-INFO +473 -0
  83. rtsm-0.1.0/rtsm.egg-info/SOURCES.txt +110 -0
  84. rtsm-0.1.0/rtsm.egg-info/dependency_links.txt +1 -0
  85. rtsm-0.1.0/rtsm.egg-info/entry_points.txt +4 -0
  86. rtsm-0.1.0/rtsm.egg-info/requires.txt +38 -0
  87. rtsm-0.1.0/rtsm.egg-info/top_level.txt +1 -0
  88. rtsm-0.1.0/setup.cfg +4 -0
  89. rtsm-0.1.0/tests/test_analytics.py +462 -0
  90. rtsm-0.1.0/tests/test_camera_feed.py +299 -0
  91. rtsm-0.1.0/tests/test_centroid.py +0 -0
  92. rtsm-0.1.0/tests/test_clip.py +0 -0
  93. rtsm-0.1.0/tests/test_debug_rgb.py +253 -0
  94. rtsm-0.1.0/tests/test_demo_components.py +392 -0
  95. rtsm-0.1.0/tests/test_depth_filter.py +0 -0
  96. rtsm-0.1.0/tests/test_faiss_client.py +10 -0
  97. rtsm-0.1.0/tests/test_image_rotation.py +157 -0
  98. rtsm-0.1.0/tests/test_ingest_gate.py +158 -0
  99. rtsm-0.1.0/tests/test_keyframe.py +30 -0
  100. rtsm-0.1.0/tests/test_mcp_embedded.py +198 -0
  101. rtsm-0.1.0/tests/test_mcp_server.py +194 -0
  102. rtsm-0.1.0/tests/test_milvus_api.py +0 -0
  103. rtsm-0.1.0/tests/test_min_area_filter.py +12 -0
  104. rtsm-0.1.0/tests/test_model_loading.py +116 -0
  105. rtsm-0.1.0/tests/test_ocr.py +0 -0
  106. rtsm-0.1.0/tests/test_proximity.py +0 -0
  107. rtsm-0.1.0/tests/test_record_replay.py +248 -0
  108. rtsm-0.1.0/tests/test_ros.py +83 -0
  109. rtsm-0.1.0/tests/test_spatial_search.py +124 -0
  110. rtsm-0.1.0/tests/test_websocket.py +375 -0
  111. rtsm-0.1.0/tests/test_websocket_e2e.py +153 -0
  112. rtsm-0.1.0/tests/test_zmq.py +83 -0
rtsm-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
rtsm-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,473 @@
1
+ Metadata-Version: 2.4
2
+ Name: rtsm
3
+ Version: 0.1.0
4
+ Summary: Real-Time Spatio-Semantic Memory for spatial AI and robotics
5
+ Requires-Python: <3.14,>=3.12
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: numpy
9
+ Requires-Dist: Pillow>=7.1.2
10
+ Requires-Dist: PyYAML>=5.3.1
11
+ Requires-Dist: requests>=2.23.0
12
+ Requires-Dist: scipy>=1.4.1
13
+ Requires-Dist: tqdm>=4.64.0
14
+ Requires-Dist: pandas>=1.1.4
15
+ Requires-Dist: opencv-python-headless>=4.6.0
16
+ Requires-Dist: psutil>=7.0.0
17
+ Requires-Dist: setuptools>=64
18
+ Requires-Dist: fastapi>=0.95.0
19
+ Requires-Dist: uvicorn[standard]>=0.22.0
20
+ Requires-Dist: prometheus-client>=0.16.0
21
+ Requires-Dist: pyzmq>=25.0.0
22
+ Provides-Extra: gpu
23
+ Requires-Dist: torch>=2.1.0; extra == "gpu"
24
+ Requires-Dist: torchvision>=0.16.0; extra == "gpu"
25
+ Requires-Dist: open-clip-torch; extra == "gpu"
26
+ Requires-Dist: sam2>=1.0; extra == "gpu"
27
+ Requires-Dist: transformers>=4.44.0; extra == "gpu"
28
+ Requires-Dist: faiss-cpu>=1.12.0; extra == "gpu"
29
+ Provides-Extra: gpu-ultralytics
30
+ Requires-Dist: rtsm[gpu]; extra == "gpu-ultralytics"
31
+ Requires-Dist: ultralytics>=8.4.0; extra == "gpu-ultralytics"
32
+ Provides-Extra: viz
33
+ Requires-Dist: open3d>=0.18.0; extra == "viz"
34
+ Requires-Dist: matplotlib>=3.2.2; extra == "viz"
35
+ Requires-Dist: seaborn>=0.11.0; extra == "viz"
36
+ Provides-Extra: mcp
37
+ Requires-Dist: mcp[cli]>=1.0.0; extra == "mcp"
38
+ Requires-Dist: httpx>=0.27.0; extra == "mcp"
39
+ Provides-Extra: all
40
+ Requires-Dist: rtsm[gpu,mcp,viz]; extra == "all"
41
+ Dynamic: license-file
42
+
43
+ ![RTSM](repo_media/background.jpg)
44
+
45
+ # RTSM — Real-Time Spatio-Semantic Memory
46
+
47
+ RTSM is a real-time spatial memory system that turns RGB-D streams into a **persistent, queryable 3D object-centric world state**.
48
+
49
+ Instead of treating perception as disposable frames, RTSM maintains **stable object identities over time**, enabling robots and embodied agents to answer questions like:
50
+ - *What objects exist in this space?*
51
+ - *Where are they right now?*
52
+ - *What changed, and when?*
53
+
54
+ **[Watch Demo Video](https://youtu.be/abhXsbvOLQg)** · **[Documentation](https://calabi-inc.github.io/rtsm)**
55
+
56
+ ---
57
+
58
+ ## Why RTSM
59
+
60
+ Modern perception systems can detect objects, but they lack **memory**.
61
+ SLAM systems build geometry, vision models detect semantics, and language models reason abstractly—but there is no shared layer that connects **space, objects, and history**.
62
+
63
+ RTSM fills this gap by acting as an explicit **spatial memory layer**:
64
+ - SLAM provides geometry and poses
65
+ - Vision models provide object masks and semantics
66
+ - RTSM fuses them into a persistent world representation
67
+
68
+ This makes spatial state **inspectable, queryable, and reusable** across robots, agents, and applications.
69
+
70
+ ---
71
+
72
+ ## What RTSM Does
73
+
74
+ - Builds a live 3D map from RGB-D + pose streams
75
+ - Assigns **persistent IDs** to objects across viewpoints and time
76
+ - Stores spatial, semantic, and temporal metadata per object
77
+ - Supports semantic + spatial queries (e.g. *"red bin near dock 3"*)
78
+ - Exposes a programmatic API and real-time 3D visualizer
79
+
80
+ RTSM is **SLAM-agnostic** and designed to sit above existing perception stacks.
81
+
82
+ ---
83
+
84
+ ## Who This Is For
85
+
86
+ - Robotics and embodied AI researchers
87
+ - Developers building agentic or world-model-based systems
88
+ - Teams exploring persistent perception, spatial reasoning, or digital twins
89
+
90
+ ---
91
+
92
+ ## Architecture
93
+
94
+ ```
95
+ ┌──────────────────────────────────────────────────────────────────────────┐
96
+ │ RTSM — Real-Time Spatio-Semantic Memory │
97
+ └──────────────────────────────────────────────────────────────────────────┘
98
+
99
+ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
100
+ │ Calabi Lens │ │ D435i + SLAM │ │ Recorded │
101
+ │ (ARKit iOS) │ │ (RTABMap) │ │ Session │
102
+ └────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
103
+ │ WebSocket │ ZeroMQ │ --replay
104
+ ▼ ▼ ▼
105
+ ┌──────────────────────────────────────────────────────────────────────────┐
106
+ │ I/O Layer │
107
+ │ │
108
+ │ ┌─────────────┐ ┌─────────────┐ ┌──────────────┐ ┌──────────────┐ │
109
+ │ │ WebSocket │ │ ZMQ Bridge │ │ Replay │ │ Recorder │ │
110
+ │ │ Receiver │ │ (sensors) │ │ Receiver │ │ (--record) │ │
111
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬───────┘ └──────────────┘ │
112
+ │ └────────────────┴────────────────┘ │
113
+ │ │ │
114
+ │ ┌──────▼───────┐ ┌──────────────┐ │
115
+ │ │ IngestQueue │────>│ FramePacket │ │
116
+ │ │ (buffer) │ │ (RGB,D,Pose) │ │
117
+ │ └──────────────┘ └──────┬───────┘ │
118
+ │ │ │
119
+ └───────────────────────────────────────────────┼──────────────────────────┘
120
+ │
121
+ ┌─────────────────────▼───────────────────────┐
122
+ │ Ingest Gate │
123
+ │ (keyframe priority, sweep-based skip) │
124
+ └─────────────────────┬───────────────────────┘
125
+ │
126
+ ┌───────────────────────────────────────────────▼──────────────────────────┐
127
+ │ Perception Pipeline │
128
+ │ │
129
+ │ ┌────────────────┐ ┌────────────────┐ │
130
+ │ │ Grounding DINO │ │ SAM2 │ Default: grounded_sam2 │
131
+ │ │ (detection + │─>│ (box-prompted │ GDINO detects → SAM2 segments │
132
+ │ │ labels) │ │ masks) │ (Apache 2.0, no AGPL) │
133
+ │ └────────────────┘ └───────┬────────┘ │
134
+ │ │ │
135
+ │ ▼ │
136
+ │ ┌───────────────┐ ┌──────────────┐ ┌──────────────┐ │
137
+ │ │ Mask Staging │────>│ Top-K Select │────>│ CLIP Encode │ │
138
+ │ │ (heuristics) │ │ (priority) │ │(224x224 crop)│ │
139
+ │ └───────────────┘ └──────────────┘ └──────┬───────┘ │
140
+ │ │ │
141
+ │ ┌───────────────┐ ┌─────▼────────┐ │
142
+ │ │ Vocab Classify│<───────│ Embeddings │ │
143
+ │ │ (label + conf)│ │ (512-D L2) │ │
144
+ │ └───────┬───────┘ └──────────────┘ │
145
+ │ │ │
146
+ └─────────────────────────────┼────────────────────────────────────────────┘
147
+ │
148
+ ▼
149
+ ┌──────────────────────────────────────────────────────────────────────────┐
150
+ │ Association │
151
+ │ │
152
+ │ ┌─────────────┐ ┌─────────────┐ ┌───────────────┐ │
153
+ │ │ Proximity │────>│ Embedding │────>│ Score Fusion │ │
154
+ │ │ Query │ │ Cosine Sim │ │ (match/create)│ │
155
+ │ └─────────────┘ └─────────────┘ └───────────────┘ │
156
+ │ │
157
+ └───────────────┬──────────────────────────────────────────────────────────┘
158
+ │
159
+ ▼
160
+ ┌──────────────────────────────────────────────────────────────────────────┐
161
+ │ Working Memory │
162
+ │ │
163
+ │ ObjectState: │
164
+ │ - id, xyz_world (3D position) │
165
+ │ - emb_mean, emb_gallery (CLIP embeddings) │
166
+ │ - view_bins (multi-view fusion) │
167
+ │ - label_scores (EWMA label confidence) │
168
+ │ - stability, hits, confirmed │
169
+ │ - image_crops (JPEG snapshots) │
170
+ │ │
171
+ │ Proto -> Confirmed (hits >= 2, stability >= 0.55, views >= 1) │
172
+ │ │
173
+ └───────────────┬──────────────────────────────────────────────────────────┘
174
+ │
175
+ ▼
176
+ ┌──────────────────────────────────────────────────────────────────────────┐
177
+ │ Long-Term Memory (FAISS / Milvus) │
178
+ │ │
179
+ │ Semantic Search: query(text) -> CLIP -> top-k objects │
180
+ │ │
181
+ └───────────────┬──────────────────────────────────────────────────────────┘
182
+ │
183
+ ▼
184
+ ┌──────────────────────────────────────────────────────────────────────────┐
185
+ │ API & Visualization │
186
+ │ │
187
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
188
+ │ │ REST API │ │ WebSocket │ │ 3D Demo │ │
189
+ │ │ /objects │ │ point clouds │ │ (Three.js) │ │
190
+ │ │ /search │ │ objects_update │ │ │ │
191
+ │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
192
+ │ │
193
+ └──────────────────────────────────────────────────────────────────────────┘
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Quick Start
199
+
200
+ ### Prerequisites
201
+
202
+ - Python 3.12+
203
+ - pip (or [uv](https://docs.astral.sh/uv/))
204
+ - CUDA-capable GPU (tested on RTX 3080, RTX 5090)
205
+ - **One of:**
206
+ - iPhone with [Calabi Lens](https://github.com/calabi-inc) app (ARKit, no external SLAM needed)
207
+ - RGB-D camera (Intel RealSense D435i) + SLAM system (RTAB-Map)
208
+ - A recorded session (for replay — no hardware needed)
209
+
210
+ > **Tested on:** WSL2 Ubuntu 22.04 with RTAB-Map, and macOS/Windows with Calabi Lens.
211
+
212
+ ### Installation
213
+
214
+ ```bash
215
+ git clone https://github.com/calabi-inc/rtsm.git
216
+ cd rtsm
217
+
218
+ # Core only (API server, I/O transports — no GPU needed)
219
+ pip install .
220
+
221
+ # With GPU — permissive license (SAM2 + Grounding DINO, Apache 2.0)
222
+ pip install ".[gpu]" --extra-index-url https://download.pytorch.org/whl/cu128
223
+
224
+ # With GPU — ultralytics backends (FastSAM + YOLOE, AGPL-3.0)
225
+ pip install ".[gpu-ultralytics]" --extra-index-url https://download.pytorch.org/whl/cu128
226
+
227
+ # Everything (GPU + visualization)
228
+ pip install ".[all]" --extra-index-url https://download.pytorch.org/whl/cu128
229
+ ```
230
+
231
+ > **License note:** `rtsm[gpu]` uses only Apache 2.0 / MIT dependencies. `rtsm[gpu-ultralytics]` adds the `ultralytics` package (AGPL-3.0) for FastSAM and YOLOE backends.
232
+ >
233
+ > **CUDA version:** Use `cu128` for most GPUs (RTX 3080–5090). For Blackwell-only features use `cu130`. See [PyTorch install](https://pytorch.org/get-started/locally/) for other options.
234
+
235
+ ### Download Models
236
+
237
+ ```bash
238
+ # Fetch default models (SAM2, Grounding DINO, CLIP)
239
+ python scripts/fetch_models.py
240
+
241
+ # Or fetch individually
242
+ python scripts/fetch_models.py --only sam2
243
+ python scripts/fetch_models.py --only gdino
244
+ python scripts/fetch_models.py --only clip
245
+
246
+ # Ultralytics models (only if you installed rtsm[gpu-ultralytics])
247
+ python scripts/fetch_models.py --only fastsam
248
+ python scripts/fetch_models.py --only yolo
249
+ ```
250
+
251
+ ### Run
252
+
253
+ ```bash
254
+ # Live — Calabi Lens (ARKit over WebSocket)
255
+ python -m rtsm
256
+
257
+ # Live — D435i + RTAB-Map (ZeroMQ)
258
+ # Set io.receiver: zeromq in config/rtsm.yaml first
259
+ python -m rtsm
260
+
261
+ # Replay a recorded session (no device needed)
262
+ python -m rtsm --replay recordings/session1
263
+ ```
264
+
265
+ RTSM will start:
266
+ - **Perception pipeline** — processing frames
267
+ - **REST API** — `http://localhost:8000`
268
+ - **Visualization WebSocket** — `ws://localhost:8081`
269
+
270
+ ### Record & Replay
271
+
272
+ Record a session for offline testing and reproducible iteration:
273
+
274
+ ```bash
275
+ # Record only (no GPU needed, no pipeline — works with core-only install)
276
+ python -m rtsm --record recordings/my_session --record-only
277
+
278
+ # Record while running pipeline
279
+ python -m rtsm --record recordings/my_session
280
+
281
+ # Replay at original recording rate
282
+ python -m rtsm --replay recordings/my_session
283
+ ```
284
+
285
+ Recordings are self-contained directories with raw WebSocket data. Replay feeds the exact same bytes through the full decode + pipeline path, preserving all time-dependent behavior (TTL caches, throttles).
286
+
287
+ ### A/B Segmentation Debug
288
+
289
+ Compare FastSAM vs YOLOE segmentation on a recorded session:
290
+
291
+ ```bash
292
+ # Generate side-by-side overlays (cached — skips existing frames)
293
+ python scripts/debug_segmentation.py --recording recordings/session1
294
+
295
+ # Open the viewer
296
+ # → debug/session1/compare.html (arrow keys to navigate)
297
+ ```
298
+
299
+ ### API Examples
300
+
301
+ ```bash
302
+ # List all objects
303
+ curl http://localhost:8000/objects
304
+
305
+ # Semantic search
306
+ curl "http://localhost:8000/search/semantic?query=red%20mug&top_k=5"
307
+
308
+ # Get system stats
309
+ curl http://localhost:8000/stats/detailed
310
+
311
+ # Runtime analytics (latency, throughput, dual confirmation rates)
312
+ curl http://localhost:8000/stats/analytics
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Configuration
318
+
319
+ See [`config/rtsm.yaml`](config/rtsm.yaml) for full configuration options:
320
+
321
+ - **Camera intrinsics** — focal length, resolution
322
+ - **I/O endpoints** — ZeroMQ addresses for camera and SLAM
323
+ - **Pipeline tuning** — mask filtering, association thresholds
324
+ - **Memory settings** — object promotion, expiry, vector store
325
+
326
+ ---
327
+
328
+ ## Segmentation Backends
329
+
330
+ RTSM supports multiple segmentation backends via `segmentation.backend` in `config/rtsm.yaml`:
331
+
332
+ | Backend | License | Description | Seg time* | Pipeline total* | Labels |
333
+ |---------|---------|-------------|-----------|-----------------|--------|
334
+ | `grounded_sam2` | Apache 2.0 | Grounding DINO detect + SAM2 segment | 222 ms | 510 ms | Open-vocab (text-prompted) |
335
+ | `sam2` | Apache 2.0 | SAM2 auto-mask (segment everything) | ~860 ms | ~1000 ms | None (class-agnostic) |
336
+ | `fastsam` | AGPL-3.0 | FastSAM (segment everything) | ~50 ms | ~200 ms | None (class-agnostic) |
337
+ | `yoloe` | AGPL-3.0 | YOLOE detection + segmentation | ~60 ms | ~210 ms | Open-vocab / 1200+ built-in |
338
+ | `dual` | AGPL-3.0 | FastSAM + YOLOE with IoU merge | 116 ms | 210 ms | Dual-confirmed labels |
339
+
340
+ *Mean on RTX 5090, 640x480 input. `dual` and `grounded_sam2` measured via replay benchmark; others estimated.*
341
+
342
+ **Default:** `grounded_sam2` — permissive license, open-vocabulary, no AGPL dependency.
343
+
344
+ To switch backends, edit `config/rtsm.yaml`:
345
+ ```yaml
346
+ segmentation:
347
+ backend: grounded_sam2 # or: sam2, fastsam, yoloe, dual
348
+ ```
349
+
350
+ > `fastsam`, `yoloe`, and `dual` require `pip install "rtsm[gpu-ultralytics]"`.
351
+
352
+ ---
353
+
354
+ ## Project Structure
355
+
356
+ ```
357
+ rtsm/
358
+ ├── core/ # Pipeline, association, ingest gate, data models
359
+ ├── models/ # SAM2, Grounding DINO, FastSAM, YOLOE, CLIP adapters
360
+ ├── stores/ # Working memory, proximity index, sweep cache, vector stores
361
+ ├── io/ # WebSocket + ZeroMQ receivers, recorder, replayer
362
+ ├── analytics/ # Runtime analytics (latency, segmentation, congestion buffers)
363
+ ├── api/ # REST API server (FastAPI)
364
+ ├── visualization/ # WebSocket server, TSDF fusion, 3D demo
365
+ └── utils/ # Mask staging, transforms, helpers
366
+ config/
367
+ ├── rtsm.yaml # Main configuration (models, thresholds, I/O)
368
+ └── clip/vocab.yaml # CLIP vocabulary
369
+ scripts/
370
+ ├── fetch_models.py # Download all models (SAM2, GDINO, CLIP, FastSAM, YOLOE)
371
+ ├── debug_segmentation.py # A/B segmentation viewer (FastSAM vs YOLOE)
372
+ └── benchmark_backends.py # Backend comparison benchmark (generates reports/)
373
+ reports/ # Benchmark results and comparison reports
374
+ recordings/ # Recorded sessions for replay testing (git-lfs)
375
+ tests/ # Unit + integration tests
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Performance
381
+
382
+ Benchmarked on RTX 5090 (32 GB), iPhone ARKit recording (162 frames, 458s indoor scene), 640x480 RGB input. Both backends run the same replay session through the identical 10-stage pipeline.
383
+
384
+ ### Backend Comparison
385
+
386
+ | Metric | dual (FastSAM + YOLOE) | grounded_sam2 (GDINO + SAM2) |
387
+ |--------|------------------------|------------------------------|
388
+ | **Mean latency** | **210 ms** | **510 ms** |
389
+ | P50 latency | 170 ms | 502 ms |
390
+ | P95 latency | 509 ms | 721 ms |
391
+ | Masks/frame | 28.8 | 13.4 |
392
+ | Objects confirmed | 60 | 35 |
393
+ | Confirmation rate | 52.2% | 45.5% |
394
+ | License | AGPL-3.0 | Apache-2.0 |
395
+
396
+ > Per-stage breakdown, dual confirmation analysis, and full methodology: **[Benchmarks](https://calabi-inc.github.io/rtsm/benchmarks/)** | [`reports/backend_comparison.md`](reports/backend_comparison.md)
397
+
398
+ ---
399
+
400
+ ## Roadmap
401
+
402
+ - [x] Dual-confirmation segmentation (FastSAM + YOLOE)
403
+ - [x] AGPL-clean default (SAM2 + Grounding DINO, Apache 2.0)
404
+ - [x] YOLOE prompt-free (1200+ LVIS categories)
405
+ - [x] WebSocket receiver for Calabi Lens (ARKit iOS)
406
+ - [x] Record/replay system for offline testing
407
+ - [x] A/B segmentation debug tooling
408
+ - [x] Real-time analytics dashboard (Looker-style, per-stage latency, dual confirmation rates, congestion detection)
409
+ - [ ] Evaluation framework (ArUco ground truth, precision/recall metrics)
410
+ - [x] Agent architecture (MCP interface)
411
+ - [ ] More communication protocols (ROS 2, gRPC)
412
+ - [ ] LLM integration for high-level queries (agentic mode)
413
+ - [ ] Dockerization
414
+
415
+ ---
416
+
417
+ ## Acknowledgments
418
+
419
+ RTSM builds on excellent open-source work:
420
+
421
+ - **SAM 2** — Ravi et al., *SAM 2: Segment Anything in Images and Videos*, 2024.
422
+ [arXiv:2408.00714](https://arxiv.org/abs/2408.00714) · [GitHub](https://github.com/facebookresearch/sam2)
423
+
424
+ - **Grounding DINO** — Liu et al., *Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection*, 2023.
425
+ [arXiv:2303.05499](https://arxiv.org/abs/2303.05499) · [GitHub](https://github.com/IDEA-Research/GroundingDINO)
426
+
427
+ - **FastSAM** — Zhao et al., *Fast Segment Anything*, 2023.
428
+ [arXiv:2306.12156](https://arxiv.org/abs/2306.12156) · [GitHub](https://github.com/CASIA-IVA-Lab/FastSAM)
429
+
430
+ - **YOLOE** — THU-MIG, *YOLOE: Real-Time Seeing Anything*, ICCV 2025.
431
+ [GitHub](https://github.com/THU-MIG/yoloe) · [Ultralytics](https://docs.ultralytics.com/models/yoloe/)
432
+
433
+ - **CLIP** — Radford et al., *Learning Transferable Visual Models From Natural Language Supervision*, 2021.
434
+ [arXiv:2103.00020](https://arxiv.org/abs/2103.00020) · [GitHub](https://github.com/openai/CLIP)
435
+
436
+ - **RTAB-Map** — Labbé & Michaud, *RTAB-Map as an Open-Source Lidar and Visual SLAM Library for Large-Scale and Long-Term Online Operation*, Journal of Field Robotics, 2019.
437
+ [Paper](https://doi.org/10.1002/rob.21831) · [GitHub](https://github.com/introlab/rtabmap)
438
+
439
+ ---
440
+
441
+ ## Cite This
442
+
443
+ If you use RTSM in your research, please cite:
444
+
445
+ ```bibtex
446
+ @software{chang2025rtsm,
447
+ author = {Chang, Chi Feng},
448
+ title = {{RTSM}: Real-Time Spatio-Semantic Memory},
449
+ year = {2025},
450
+ url = {https://github.com/calabi-inc/rtsm},
451
+ note = {Object-centric queryable memory for spatial AI and robotics}
452
+ }
453
+ ```
454
+
455
+ ---
456
+
457
+ ## Community
458
+
459
+ This project is under active development. If you have questions or run into issues, feel free to open an issue — I'm happy to help.
460
+
461
+ If you find RTSM useful, please consider giving it a star! I'm also looking for design partners — reach out to [Calabi](https://github.com/calabi-team) if you're interested in collaborating.
462
+
463
+ ---
464
+
465
+ ## License
466
+
467
+ Apache-2.0
468
+
469
+ ---
470
+
471
+ ## Author
472
+
473
+ Built by [Chi Feng, Chang](https://github.com/vipipi)