Spaces:
Sleeping
Sleeping
Javier commited on
Commit ·
60d42dc
1
Parent(s): e4d2ec9
Added gitignore, updated README.md
Browse files- .gitignore +18 -0
- README.md +112 -3
.gitignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.py[cod]
|
| 3 |
+
.pytest_cache/
|
| 4 |
+
.ruff_cache/
|
| 5 |
+
.mypy_cache/
|
| 6 |
+
.venv/
|
| 7 |
+
venv/
|
| 8 |
+
.local/
|
| 9 |
+
.ultralytics/
|
| 10 |
+
outputs/
|
| 11 |
+
models/
|
| 12 |
+
*.webm
|
| 13 |
+
*.mp4
|
| 14 |
+
*.avi
|
| 15 |
+
*.mov
|
| 16 |
+
*.pt
|
| 17 |
+
*.onnx
|
| 18 |
+
*.engine
|
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: Tiny Trigger
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
|
@@ -9,7 +9,116 @@ python_version: '3.13'
|
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: other
|
| 12 |
-
short_description: '
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Tiny Trigger
|
| 3 |
+
emoji: "🔌"
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
|
|
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: other
|
| 12 |
+
short_description: 'Open-vocabulary video automations with YOLOE and llama.cpp'
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# Tiny Trigger
|
| 16 |
+
|
| 17 |
+
Tiny Trigger is a local-first hackathon prototype for open-vocabulary video
|
| 18 |
+
automations. It uses YOLOE to detect user-supplied classes in a video, then
|
| 19 |
+
evaluates small structured rules that can trigger simulated actions or optional
|
| 20 |
+
webhook POSTs.
|
| 21 |
+
|
| 22 |
+
The LLM path is intentionally constrained: llama.cpp compiles natural language
|
| 23 |
+
into JSON/YAML automation rules. The app validates those rules before evaluating
|
| 24 |
+
them, and the LLM never emits executable code.
|
| 25 |
+
|
| 26 |
+
## Run Locally
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
pip install -r requirements.txt
|
| 30 |
+
python app.py
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
Or with Poetry:
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
poetry install
|
| 37 |
+
poetry run python app.py
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
The detector defaults to `yoloe-26s-seg.pt`, which Ultralytics downloads on
|
| 41 |
+
first use if it is not already cached.
|
| 42 |
+
|
| 43 |
+
For small or background objects, use a larger model such as `yoloe-26l-seg.pt`,
|
| 44 |
+
set device to `cuda:0`, lower confidence to `0.05`-`0.15`, and raise image size
|
| 45 |
+
to `960` or `1280`.
|
| 46 |
+
|
| 47 |
+
Run tests with:
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
pip install -r requirements-dev.txt
|
| 51 |
+
python -m pytest
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
Or:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
poetry run pytest
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## llama.cpp Rule Compiler
|
| 61 |
+
|
| 62 |
+
Start a llama.cpp server with the small GGUF model:
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
llama-server -hf ggml-org/Qwen3-1.7B-GGUF:Q4_K_M
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
Then use the default compiler endpoint in the UI:
|
| 69 |
+
|
| 70 |
+
```text
|
| 71 |
+
http://127.0.0.1:8080/v1
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## Rule Shape
|
| 75 |
+
|
| 76 |
+
Rules can be written directly as YAML or compiled from natural language:
|
| 77 |
+
|
| 78 |
+
```yaml
|
| 79 |
+
rules:
|
| 80 |
+
- name: person-near-steering-wheel
|
| 81 |
+
when:
|
| 82 |
+
all:
|
| 83 |
+
- present: {label: person, min_count: 1}
|
| 84 |
+
- near: {a: person, b: steering wheel, max_distance: 0.45}
|
| 85 |
+
gate:
|
| 86 |
+
enabled: true
|
| 87 |
+
cooldown: {key: turn-on-pc, minutes: 5}
|
| 88 |
+
then:
|
| 89 |
+
- type: webhook
|
| 90 |
+
name: turn on pc
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
Initial video conditions include presence, count, and near. Gates include enabled
|
| 94 |
+
state and cooldown. Initial actions are simulated events and optional webhooks.
|
| 95 |
+
Home Assistant, live RTSP/webcam monitoring, and trajectory logic are planned
|
| 96 |
+
later increments.
|
| 97 |
+
|
| 98 |
+
## Local State
|
| 99 |
+
|
| 100 |
+
Private local settings and runtime memory live under `.local/`, which is ignored
|
| 101 |
+
by git:
|
| 102 |
+
|
| 103 |
+
```text
|
| 104 |
+
.local/config.yaml private defaults such as camera/webhook URLs
|
| 105 |
+
.local/automations.json saved editable automation rules
|
| 106 |
+
.local/state.json cooldown memory and last-fired timestamps
|
| 107 |
+
.local/events.jsonl append-only fired action history
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
Example `.local/config.yaml`:
|
| 111 |
+
|
| 112 |
+
```yaml
|
| 113 |
+
webhook_url: "http://127.0.0.1:8123/api/webhook/example"
|
| 114 |
+
default_detector_model: "yoloe-26x-seg.pt"
|
| 115 |
+
default_device: "cuda:0"
|
| 116 |
+
default_image_size: 1280
|
| 117 |
+
default_max_detections: 300
|
| 118 |
+
llamacpp_base_url: "http://127.0.0.1:8080/v1"
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
## License
|
| 122 |
+
|
| 123 |
+
This repository is provided under a temporary all-rights-reserved hackathon
|
| 124 |
+
prototype license. See `LICENSE`.
|