sightrag 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.
sightrag-0.1.0/LICENSE ADDED
@@ -0,0 +1,125 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including
45
+ the original version of the Work and any modifications or additions
46
+ to that Work or Derivative Works thereof, that is intentionally
47
+ submitted to the Licensor for inclusion in the Work by the copyright owner
48
+ or by an individual or Legal Entity authorized to submit on behalf of
49
+ the copyright owner.
50
+
51
+ "Contributor" shall mean Licensor and any individual or Legal Entity
52
+ on behalf of whom a Contribution has been received by the Licensor and
53
+ subsequently incorporated within the Work.
54
+
55
+ 2. Grant of Copyright License. Subject to the terms and conditions of
56
+ this License, each Contributor hereby grants to You a perpetual,
57
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
58
+ copyright license to reproduce, prepare Derivative Works of,
59
+ publicly display, publicly perform, sublicense, and distribute the
60
+ Work and such Derivative Works in Source or Object form.
61
+
62
+ 3. Grant of Patent License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ (except as stated in this section) patent license to make, have made,
66
+ use, offer to sell, sell, import, and otherwise transfer the Work,
67
+ where such license applies only to those patent claims licensable
68
+ by such Contributor that are necessarily infringed by their
69
+ Contribution(s) alone or by combination of their Contribution(s)
70
+ with the Work to which such Contribution(s) was submitted.
71
+
72
+ 4. Redistribution. You may reproduce and distribute copies of the
73
+ Work or Derivative Works thereof in any medium, with or without
74
+ modifications, and in Source or Object form, provided that You
75
+ meet the following conditions:
76
+
77
+ (a) You must give any other recipients of the Work or
78
+ Derivative Works a copy of this License; and
79
+
80
+ (b) You must cause any modified files to carry prominent notices
81
+ stating that You changed the files; and
82
+
83
+ (c) You must retain, in the Source form of any Derivative Works
84
+ that You distribute, all copyright, patent, trademark, and
85
+ attribution notices from the Source form of the Work,
86
+ excluding those notices that do not pertain to any part of
87
+ the Derivative Works; and
88
+
89
+ (d) If the Work includes a "NOTICE" text file as part of its
90
+ distribution, then any Derivative Works that You distribute must
91
+ include a readable copy of the attribution notices contained
92
+ within such NOTICE file, excluding any notices that do not
93
+ pertain to any part of the Derivative Works, in at least one
94
+ of the following places: within a NOTICE text file distributed
95
+ as part of the Derivative Works; within the Source form or
96
+ documentation, if provided along with the Derivative Works; or,
97
+ within a display generated by the Derivative Works, if and
98
+ wherever such third-party notices normally appear.
99
+
100
+ 5. Submission of Contributions.
101
+
102
+ 6. Trademarks. This License does not grant permission to use the trade
103
+ names, trademarks, service marks, or product names of the Licensor.
104
+
105
+ 7. Disclaimer of Warranty. Unless required by applicable law or
106
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
107
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
108
+
109
+ 8. Limitation of Liability.
110
+
111
+ 9. Accepting Warranty or Additional Liability.
112
+
113
+ Copyright 2026 Ant (VK-Ant)
114
+
115
+ Licensed under the Apache License, Version 2.0 (the "License");
116
+ you may not use this file except in compliance with the License.
117
+ You may obtain a copy of the License at
118
+
119
+ http://www.apache.org/licenses/LICENSE-2.0
120
+
121
+ Unless required by applicable law or agreed to in writing, software
122
+ distributed under the License is distributed on an "AS IS" BASIS,
123
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124
+ See the License for the specific language governing permissions and
125
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include README.md
3
+ include requirements.txt
4
+ recursive-include sightrag *.py
@@ -0,0 +1,391 @@
1
+ Metadata-Version: 2.4
2
+ Name: sightrag
3
+ Version: 0.1.0
4
+ Summary: SightRAG — Image and Video RAG. See. Search. Retrieve.
5
+ Home-page: https://github.com/VK-Ant/sightrag
6
+ Author: Ant (VK-Ant)
7
+ Author-email:
8
+ License: Apache-2.0
9
+ Project-URL: Homepage, https://github.com/VK-Ant/sightrag
10
+ Project-URL: Issues, https://github.com/VK-Ant/sightrag/issues
11
+ Keywords: computer-vision,rag,image-search,video-search,retrieval,clip,yolo
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: torch>=2.0.0
23
+ Requires-Dist: torchvision>=0.15.0
24
+ Requires-Dist: transformers>=4.30.0
25
+ Requires-Dist: ultralytics>=8.0.0
26
+ Requires-Dist: opencv-python>=4.8.0
27
+ Requires-Dist: Pillow>=9.0.0
28
+ Requires-Dist: numpy>=1.24.0
29
+ Provides-Extra: chroma
30
+ Requires-Dist: chromadb>=0.4.0; extra == "chroma"
31
+ Provides-Extra: api
32
+ Requires-Dist: fastapi>=0.100.0; extra == "api"
33
+ Requires-Dist: uvicorn>=0.23.0; extra == "api"
34
+ Requires-Dist: python-multipart>=0.0.6; extra == "api"
35
+ Provides-Extra: all
36
+ Requires-Dist: chromadb>=0.4.0; extra == "all"
37
+ Requires-Dist: fastapi>=0.100.0; extra == "all"
38
+ Requires-Dist: uvicorn>=0.23.0; extra == "all"
39
+ Requires-Dist: python-multipart>=0.0.6; extra == "all"
40
+ Dynamic: home-page
41
+ Dynamic: license-file
42
+ Dynamic: requires-python
43
+
44
+ <p align="center">
45
+ <img src="https://raw.githubusercontent.com/VK-Ant/sightrag/main/assets/sightrag_banner.png" alt="SightRAG Banner" width="100%">
46
+ </p>
47
+
48
+ <h1 align="center">SightRAG</h1>
49
+ <h3 align="center">See. Search. Retrieve.</h3>
50
+
51
+ <p align="center">
52
+ <a href="https://pypi.org/project/sightrag/"><img src="https://img.shields.io/pypi/v/sightrag" alt="PyPI"></a>
53
+ <a href="https://github.com/VK-Ant/sightrag/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License"></a>
54
+ <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.9+-green" alt="Python"></a>
55
+ </p>
56
+
57
+ <p align="center">
58
+ Search your images and videos with plain English. Three lines of code.
59
+ </p>
60
+
61
+ ---
62
+
63
+ ## Quick Start
64
+
65
+ ```python
66
+ from sightrag import SightRAG
67
+
68
+ rag = SightRAG()
69
+ rag.index("./photos/")
70
+ results = rag.query("find empty shelf")
71
+ ```
72
+
73
+ ## Install
74
+
75
+ ```bash
76
+ pip install sightrag
77
+ ```
78
+
79
+ For REST API:
80
+ ```bash
81
+ pip install sightrag[api]
82
+ ```
83
+
84
+ ## What SightRAG Does
85
+
86
+ Point SightRAG at any image folder, video file, or camera. Ask in plain English. Get back matched images with bounding boxes, timestamps, and confidence scores.
87
+
88
+ SightRAG is not a model. Not a wrapper. Not a framework plugin. It is a complete retrieval system that handles detection, embedding, indexing, and search — so you don't have to.
89
+
90
+ All models and indexes are stored in `~/.sightrag/` — your project folder stays clean.
91
+
92
+ ## Project Structure
93
+
94
+ ```
95
+ sightrag/
96
+ ├── sightrag/ ← main library (pip install)
97
+ │ ├── core.py ← SightRAG class
98
+ │ ├── detector.py ← YOLO detection
99
+ │ ├── embedder.py ← CLIP embeddings
100
+ │ ├── indexer.py ← image/video/camera indexing
101
+ │ ├── retriever.py ← text + reference queries
102
+ │ ├── api.py ← REST API (FastAPI)
103
+ │ ├── store/
104
+ │ │ ├── base.py ← abstract store interface
105
+ │ │ ├── sqlite_store.py ← SQLite fallback
106
+ │ │ └── chroma_store.py ← ChromaDB (default)
107
+ │ └── utils/
108
+ │ ├── image.py ← image loading
109
+ │ ├── video.py ← frame extraction
110
+ │ └── camera.py ← webcam capture
111
+
112
+ ├── demo_sightrag/ ← test locally — run the scripts
113
+ │ ├── sightrag_images.py ← demo: image folder indexing
114
+ │ ├── sightrag_video.py ← demo: video file indexing
115
+ │ ├── sightrag_livecam.py ← demo: live webcam capture
116
+ │ ├── sightrag_restapi.py ← demo: REST API usage
117
+ │ ├── input_images/ ← sample images to index
118
+ │ ├── reference_images/ ← sample reference query images
119
+ │ ├── camera_captures/ ← webcam frames stored here
120
+ │ └── video_samples/ ← put your videos here
121
+
122
+ ├── notebooks/ ← test on Google Colab
123
+ │ └── SightRAG_Colab_Demo.ipynb
124
+
125
+ ├── examples/ ← code examples
126
+ │ ├── basic_usage.py
127
+ │ ├── camera_example.py
128
+ │ ├── custom_domain_example.py
129
+ │ └── rest_api_example.py
130
+
131
+ ├── tests/ ← unit tests
132
+ │ └── test_core.py
133
+
134
+ ├── docs/ ← documentation
135
+ │ └── DOCKER.md
136
+
137
+ ├── assets/ ← banner image
138
+ ├── setup.py ← PyPI packaging
139
+ ├── pyproject.toml ← build config
140
+ ├── requirements.txt ← dependencies
141
+ ├── Dockerfile ← container
142
+ ├── docker-compose.yml ← one command deploy
143
+ ├── LICENSE ← Apache 2.0
144
+ └── test_sightrag.py ← quick test script
145
+ ```
146
+
147
+ ## How To Test
148
+
149
+ ### Quick Test (terminal)
150
+ ```bash
151
+ python test_sightrag.py
152
+ ```
153
+
154
+ ### Demo Scripts (test each mode)
155
+ ```bash
156
+ python demo_sightrag/sightrag_images.py # image folder
157
+ python demo_sightrag/sightrag_video.py # video files
158
+ python demo_sightrag/sightrag_livecam.py # live webcam
159
+ python demo_sightrag/sightrag_restapi.py # REST API
160
+ ```
161
+
162
+ ### Google Colab
163
+ Upload `notebooks/SightRAG_Colab_Demo.ipynb` to Google Colab → Run All
164
+
165
+ ### Unit Tests
166
+ ```bash
167
+ pip install pytest
168
+ python -m pytest tests/ -v
169
+ ```
170
+
171
+ ## Usage
172
+
173
+ ### Image Folder
174
+
175
+ ```python
176
+ from sightrag import SightRAG
177
+
178
+ rag = SightRAG()
179
+ rag.index("./shelf_photos/")
180
+ results = rag.query("find empty shelf near dairy")
181
+
182
+ for r in results:
183
+ print(f"{r['image_path']} — score: {r['score']} — {r['label']}")
184
+ ```
185
+
186
+ ### Video File
187
+
188
+ ```python
189
+ rag = SightRAG()
190
+ rag.index("./cctv_footage.mp4")
191
+ results = rag.query("person near exit door")
192
+
193
+ for r in results:
194
+ print(f"Timestamp: {r['timestamp']} — score: {r['score']}")
195
+ ```
196
+
197
+ ### Mixed Folder (images + videos)
198
+
199
+ ```python
200
+ rag = SightRAG()
201
+ rag.index("./my_data/") # automatically detects images AND videos
202
+ ```
203
+
204
+ ### Live Camera
205
+
206
+ ```python
207
+ rag = SightRAG()
208
+ rag.index(source="camera") # default webcam
209
+ rag.index(source="camera", camera_id=1) # specific camera
210
+ results = rag.query("find person")
211
+ ```
212
+
213
+ ### Reference Image Query
214
+
215
+ ```python
216
+ results = rag.query(reference="sample_shelf.jpg")
217
+ ```
218
+
219
+ ### Custom Domain (medical, industrial, satellite)
220
+
221
+ ```python
222
+ rag = SightRAG(domain_hint="pcb defect solder joint circuit board")
223
+ rag.index("./circuit_boards/")
224
+ results = rag.query("find defective solder joint")
225
+ ```
226
+
227
+ ### SQLite Fallback (lightweight)
228
+
229
+ ```python
230
+ rag = SightRAG(store="sqlite")
231
+ rag.index("./small_dataset/")
232
+ ```
233
+
234
+ ## REST API
235
+
236
+ ```bash
237
+ pip install sightrag[api]
238
+ ```
239
+
240
+ Start the server:
241
+
242
+ ```bash
243
+ # Command line
244
+ sightrag-server
245
+
246
+ # Or from Python
247
+ from sightrag import serve
248
+ serve(port=8000)
249
+
250
+ # Or Docker (API starts automatically)
251
+ docker-compose up
252
+ ```
253
+
254
+ API available at `http://localhost:8000`
255
+
256
+ ### Endpoints
257
+
258
+ | Method | Endpoint | Description |
259
+ |--------|----------|-------------|
260
+ | GET | `/` | API info and available endpoints |
261
+ | GET | `/status` | Index count, store type, domain hint |
262
+ | POST | `/index/folder` | Index all images and videos in a folder |
263
+ | POST | `/index/video` | Index a video file |
264
+ | POST | `/index/upload` | Upload and index images directly |
265
+ | POST | `/query/text` | Search with plain English text |
266
+ | POST | `/query/reference` | Search with a reference image |
267
+ | DELETE | `/index` | Clear all indexed data |
268
+
269
+ ### Examples
270
+
271
+ ```bash
272
+ # Index a folder
273
+ curl -X POST http://localhost:8000/index/folder \
274
+ -F "path=./data/"
275
+
276
+ # Search with text
277
+ curl -X POST http://localhost:8000/query/text \
278
+ -F "text=find empty shelf" \
279
+ -F "top_k=5"
280
+
281
+ # Upload and search with reference image
282
+ curl -X POST http://localhost:8000/query/reference \
283
+ -F "file=@new_photo.jpg" \
284
+ -F "top_k=5"
285
+
286
+ # Check status
287
+ curl http://localhost:8000/status
288
+ ```
289
+
290
+ Interactive API docs available at `http://localhost:8000/docs` (Swagger UI).
291
+
292
+ ## Result Format
293
+
294
+ ```python
295
+ [
296
+ {
297
+ "image_path": "./photos/shelf_042.jpg",
298
+ "score": 0.9134,
299
+ "label": "bottle",
300
+ "confidence": 0.8721,
301
+ "bbox": [120, 45, 380, 290],
302
+ "timestamp": "",
303
+ "source_type": "image"
304
+ }
305
+ ]
306
+ ```
307
+
308
+ ## Storage
309
+
310
+ SightRAG uses a built-in SQLite vector store by default — zero extra dependencies, works everywhere.
311
+
312
+ | Store | Scale | Cost | Usage |
313
+ |-------|-------|------|-------|
314
+ | SQLite (default) | Up to 100k images | Free | `SightRAG()` |
315
+ | ChromaDB (optional) | Large scale | Free | `SightRAG(store="chroma")` |
316
+
317
+ Enterprise connectors (Qdrant, Pinecone, Azure) coming in v2.
318
+
319
+ ## Where SightRAG Stores Data
320
+
321
+ ```
322
+ ~/.sightrag/
323
+ ├── models/ ← YOLO weights (auto-downloaded once)
324
+ └── index/ ← vector database (ChromaDB/SQLite)
325
+ ```
326
+
327
+ Your project folder stays clean. No random `.pt` files or `sightrag_index/` folders appearing.
328
+
329
+ ## Docker
330
+
331
+ ```bash
332
+ docker-compose up
333
+ ```
334
+
335
+ This starts the REST API server on port 8000. See [Docker Guide](docs/DOCKER.md) for details.
336
+
337
+ ## Architecture
338
+
339
+ ```
340
+ Input (images / video / camera / reference image)
341
+
342
+ Preprocessor (resize, validate, keyframe extract)
343
+
344
+ YOLO Detection (80 COCO classes + whole-image fallback)
345
+
346
+ CLIP Embedding (domain_hint enrichment for custom domains)
347
+
348
+ Vector Store (ChromaDB default / SQLite fallback)
349
+
350
+ Retrieval + Ranking (cosine similarity, confidence scoring)
351
+
352
+ Output (matched images, timestamps, bounding boxes, scores)
353
+ ```
354
+
355
+ ## Honest Limitations (v0.1.0)
356
+
357
+ - Indexing ~500 images takes ~2 minutes on CPU (one-time cost — search is instant after)
358
+ - Custom domains (medical, satellite) use whole-image CLIP without region grounding
359
+ - Single webcam only (multiple cameras in v2)
360
+ - SQLite vector store loads all vectors into memory for search
361
+
362
+ ## Roadmap
363
+
364
+ | Version | Features |
365
+ |---------|----------|
366
+ | v0.1 (current) | Image + Video + Camera + REST API + ChromaDB |
367
+ | v0.2 | C++ core, CLI, Grounding DINO, SAM |
368
+ | v0.3 | Person Re-ID, scene graph, edge deployment |
369
+ | v1.0 | Jetson Orin, compliance modes (GDPR/HIPAA/DPDP) |
370
+
371
+ ## Three Library Ecosystem
372
+
373
+ SightRAG is part of the VK-Ant AI ecosystem:
374
+
375
+ | Library | Purpose | Status |
376
+ |---------|---------|--------|
377
+ | [SightRAG](https://github.com/VK-Ant/sightrag) | Image & Video RAG | v0.1 |
378
+ | [adaptive-intelligence](https://pypi.org/project/adaptive-intelligence/) | RL-based RAG orchestration | v4.0 |
379
+ | [llmevalkit](https://pypi.org/project/llmevalkit/) | LLM evaluation (97+ tests) | Stable |
380
+
381
+ ## License
382
+
383
+ Apache 2.0 — see [LICENSE](LICENSE)
384
+
385
+ ## Author
386
+
387
+ Built by **Ant (VK-Ant)** — Kaggle Master, 8.5+ years computer vision experience.
388
+
389
+ - GitHub: [VK-Ant](https://github.com/VK-Ant)
390
+ - LinkedIn: [VK-Ant](https://linkedin.com/in/vk-ant)
391
+ - Portfolio: [vk-ant.github.io](https://vk-ant.github.io/Venkatkumar)