Skip to content

Commit ec559cf

Browse files
committed
feat(yolo-coral-tpu): migrate completely to native inline OS GUI driver deployments
- Drop all Docker architecture dependencies - Remove Aegis manual_setup firewall pre-conditions - Implement native ask_sudo wrapped in osascript/pkexec for UI collection - Fully script bare-metal Windows UAC powershell payload handling
1 parent 51a107e commit ec559cf

3 files changed

Lines changed: 259 additions & 106 deletions

File tree

skills/detection/yolo-detection-2026-coral-tpu/SKILL.md

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: yolo-detection-2026-coral-tpu
3-
description: "Google Coral Edge TPU — real-time object detection via Docker"
3+
description: "Google Coral Edge TPU — real-time object detection natively via local Python environment"
44
version: 1.0.0
55
icon: assets/icon.png
66
entry: scripts/monitor.js
@@ -10,18 +10,7 @@ runtime: node
1010
requirements:
1111
platforms: ["linux", "macos", "windows"]
1212

13-
manual_setup:
14-
macos: |
15-
# 1. Fix Homebrew permissions and install libusb
16-
sudo chown -R $(whoami) /opt/homebrew
17-
brew install libusb
1813

19-
# 2. Add Apple Silicon Edge TPU native driver
20-
curl -sSLO https://github.com/feranick/libedgetpu/releases/download/16.0TF2.19.1-1/libedgetpu-16.0-tf2.19.1-1_MacOS_Silicon.zip
21-
unzip -q -o libedgetpu-16.0-tf2.19.1-1_MacOS_Silicon.zip
22-
sudo mkdir -p /usr/local/lib
23-
sudo cp libedgetpu.1.dylib /usr/local/lib/
24-
rm -rf libedgetpu*
2514

2615
parameters:
2716
- name: auto_start
@@ -90,13 +79,13 @@ mutex: detection
9079

9180
# Coral TPU Object Detection
9281

93-
Real-time object detection using Google Coral Edge TPU accelerator. Runs inside Docker for cross-platform support. Detects 80 COCO classes (person, car, dog, cat, etc.) with ~4ms inference on 320×320 input.
82+
Real-time object detection natively utilizing the Google Coral Edge TPU accelerator on your local hardware. Detects 80 COCO classes (person, car, dog, cat, etc.) with ~4ms inference on 320x320 input.
9483

9584
## Requirements
9685

9786
- **Google Coral USB Accelerator** (USB 3.0 port recommended)
98-
- **Docker Desktop 4.35+** (all platforms — Linux, macOS, Windows)
99-
- USB 3.0 cable (the included cable is recommended)
87+
- **libusb** framework (installed automatically on Linux/macOS)
88+
- Python 3 with the native `pycoral` environment
10089
- Adequate cooling for sustained inference
10190

10291
## How It Works
@@ -106,61 +95,50 @@ Real-time object detection using Google Coral Edge TPU accelerator. Runs inside
10695
│ Host (Aegis-AI) │
10796
│ frame.jpg → /tmp/aegis_detection/ │
10897
│ stdin ──→ ┌──────────────────────────────┐ │
109-
│ │ Docker Container │ │
98+
│ │ Native Python Environment │ │
11099
│ │ detect.py │ │
111100
│ │ ├─ loads _edgetpu.tflite │ │
112-
│ │ ├─ reads frame from volume │ │
101+
│ │ ├─ reads frame from disk │ │
113102
│ │ └─ runs inference on TPU │ │
114103
│ stdout ←── │ → JSONL detections │ │
115104
│ └──────────────────────────────┘ │
116-
│ USB ──→ /dev/bus/usb (Linux) or USB/IP (Mac/Win)
105+
│ USB ──→ Native System USB / edgetpu drivers
117106
└─────────────────────────────────────────────────────┘
118107
```
119108

120-
1. Aegis writes camera frame JPEG to shared `/tmp/aegis_detection/` volume
121-
2. Sends `frame` event via stdin JSONL to Docker container
122-
3. `detect.py` reads frame, runs inference on Edge TPU
109+
1. Aegis writes camera frame JPEG to shared `/tmp/aegis_detection/` workspace
110+
2. Sends `frame` event via stdin JSONL to the local Python instance
111+
3. `detect.py` invokes PyCoral and executes natively on the mapped USB Edge TPU
123112
4. Returns `detections` event via stdout JSONL
124-
5. Same protocol as `yolo-detection-2026` — Aegis sees no difference
125113

126114
## Platform Setup
127115

128116
### Linux
129117
```bash
130-
# USB Coral should be auto-detected
131-
# Docker uses --device /dev/bus/usb for direct access
118+
# Uses the official apt-get google-coral packages natively
132119
./deploy.sh
133120
```
134121

135-
### macOS (Docker Desktop 4.35+)
122+
### macOS
136123
```bash
137-
# Docker Desktop USB/IP handles USB passthrough
138-
# ARM64 Docker image builds natively on Apple Silicon
124+
# Downloads and installs the libedgetpu OS payload framework inline
139125
./deploy.sh
140126
```
141127

142128
### Windows
143129
```powershell
144-
# Docker Desktop 4.35+ with USB/IP support
145-
# Or WSL2 backend with usbipd-win
130+
# Installs directly to the Microsoft runtime
146131
.\deploy.bat
147132
```
148133

149-
## Model
150-
151-
Ships with pre-compiled `yolo26n_edgetpu.tflite` (YOLO 2026 nano, INT8 quantized, 320×320). To compile custom models:
152-
153-
```bash
154-
# Requires x86_64 Linux or Docker --platform linux/amd64
155-
python scripts/compile_model.py --model yolo26s --size 320
156-
```
134+
> **Important Deployment Notice**: The updated `deploy.sh` script will natively halt execution and prompt you securely for your OS `sudo` password to securely register the USB drivers (`libedgetpu`) system-wide. If you refuse the prompt, it gracefully outputs the exact terminal instructions for you to configure it manually.
157135
158136
## Performance
159137

160138
| Input Size | Inference | On-chip | Notes |
161139
|-----------|-----------|---------|-------|
162-
| 320×320 | ~4ms | 100% | Fully on TPU, best for real-time |
163-
| 640×640 | ~20ms | Partial | Some layers on CPU (model segmented) |
140+
| 320x320 | ~4ms | 100% | Fully on TPU, best for real-time |
141+
| 640x640 | ~20ms | Partial | Some layers on CPU (model segmented) |
164142

165143
> **Cooling**: The USB Accelerator aluminum case acts as a heatsink. If too hot to touch during continuous inference, it will thermal-throttle. Consider active cooling or `clock_speed: standard`.
166144
@@ -184,4 +162,4 @@ Same JSONL as `yolo-detection-2026`:
184162
./deploy.sh
185163
```
186164

187-
The deployer builds the Docker image locally, probes for TPU devices, and sets the runtime command. No packages pulled from external registries beyond Docker base images and Coral apt repo.
165+
The deployer builds the local native Python virtual environment inline with global TPU hooks. No Docker containers or abstract container-bindings are used.
Lines changed: 114 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,147 @@
11
@echo off
2-
REM deploy.bat — Docker-based bootstrapper for Coral TPU Detection Skill (Windows)
2+
REM deploy.bat — Native local bootstrapper for Coral TPU Detection Skill (Windows)
33
REM
4-
REM Builds the Docker image locally and verifies Edge TPU connectivity.
5-
REM Called by Aegis skill-runtime-manager during installation.
4+
REM Builds a local Python virtual environment and installs the Google Coral Edge TPU
5+
REM natively on the host OS. Safely triggers UAC elevation for driver installation.
66
REM
7-
REM Requires: Docker Desktop 4.35+ with USB/IP support
7+
REM Exit codes:
8+
REM 0 = success
9+
REM 1 = fatal error (Python/pip not found or UAC denied)
10+
REM 2 = partial success (no TPU detected, will use CPU fallback)
811

912
setlocal enabledelayedexpansion
1013

1114
set "SKILL_DIR=%~dp0"
12-
set "IMAGE_NAME=aegis-coral-tpu"
13-
set "IMAGE_TAG=latest"
1415
set "LOG_PREFIX=[coral-tpu-deploy]"
1516

16-
REM ─── Step 1: Check Docker ────────────────────────────────────────────────
17+
REM Ensure we run inside the correct folder
18+
cd /d "%SKILL_DIR%"
1719

18-
where docker >nul 2>&1
20+
echo %LOG_PREFIX% Platform: Windows 1>&2
21+
echo {"event": "progress", "stage": "platform", "message": "Windows native environment detected"}
22+
23+
REM ─── Step 1: Install Native OS TPU Drivers (UAC Promoted) ───────────────
24+
25+
echo %LOG_PREFIX% Downloading Google official x64 Windows installer... 1>&2
26+
27+
set "TMP_DIR=%TEMP%\coral_tpu_install"
28+
if not exist "%TMP_DIR%" mkdir "%TMP_DIR%"
29+
cd /d "%TMP_DIR%"
30+
31+
powershell -Command "Invoke-WebRequest -Uri 'https://github.com/google-coral/libedgetpu/releases/download/release-grouper/edgetpu_runtime_20221024.zip' -OutFile 'edgetpu_runtime_20221024.zip'"
1932
if %errorlevel% neq 0 (
20-
echo %LOG_PREFIX% ERROR: Docker not found. Install Docker Desktop 4.35+ 1>&2
21-
echo {"event": "error", "stage": "docker", "message": "Docker not found. Install Docker Desktop 4.35+"}
33+
echo %LOG_PREFIX% ERROR: Failed to download Edge TPU runtime. 1>&2
2234
exit /b 1
2335
)
2436

25-
docker info >nul 2>&1
37+
powershell -Command "Expand-Archive -Path 'edgetpu_runtime_20221024.zip' -DestinationPath '.' -Force"
38+
cd edgetpu_runtime
39+
40+
echo %LOG_PREFIX% Prompting for Administrator rights to install drivers... 1>&2
41+
echo {"event": "progress", "stage": "platform", "message": "UAC required: Install Google Coral Edge TPU Windows Runtime"}
42+
43+
REM Start the official install script elevated. Wait for it to finish.
44+
powershell -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'install.bat < nul' -Verb RunAs -Wait"
45+
2646
if %errorlevel% neq 0 (
27-
echo %LOG_PREFIX% ERROR: Docker daemon not running. Start Docker Desktop. 1>&2
28-
echo {"event": "error", "stage": "docker", "message": "Docker daemon not running"}
47+
echo.
48+
echo [MANUAL SETUP REQUIRED] UAC prompt was skipped or user aborted.
49+
echo Please execute the following fragile instructions manually in an Administrator console:
50+
echo.
51+
echo powershell -Command "Invoke-WebRequest -Uri 'https://github.com/google-coral/libedgetpu/releases/download/release-grouper/edgetpu_runtime_20221024.zip' -OutFile 'edgetpu_runtime_20221024.zip'"
52+
echo powershell -Command "Expand-Archive -Path 'edgetpu_runtime_20221024.zip' -DestinationPath '.'"
53+
echo cd edgetpu_runtime
54+
echo install.bat
55+
echo.
56+
echo Once completed, re-run this deployment.
57+
echo {"event": "error", "stage": "platform", "message": "Manual OS setup required (UAC skipped)"}
58+
cd /d "%SKILL_DIR%"
59+
rmdir /S /Q "%TMP_DIR%"
2960
exit /b 1
3061
)
3162

32-
for /f "tokens=*" %%v in ('docker version --format "{{.Server.Version}}" 2^>nul') do set "DOCKER_VER=%%v"
33-
echo %LOG_PREFIX% Using Docker (version: %DOCKER_VER%) 1>&2
34-
echo {"event": "progress", "stage": "docker", "message": "Docker ready (%DOCKER_VER%)"}
63+
cd /d "%SKILL_DIR%"
64+
rmdir /S /Q "%TMP_DIR%"
3565

36-
REM ─── Step 2: Build Docker image ──────────────────────────────────────────
66+
REM ─── Step 2: Ensure Python 3 ──────────────────────────────────────────────
3767

38-
echo %LOG_PREFIX% Building Docker image: %IMAGE_NAME%:%IMAGE_TAG% ... 1>&2
39-
echo {"event": "progress", "stage": "build", "message": "Building Docker image..."}
68+
set "PYTHON_CMD=python"
69+
python --version >nul 2>&1
70+
if %errorlevel% neq 0 (
71+
python3 --version >nul 2>&1
72+
if !errorlevel! equ 0 (
73+
set "PYTHON_CMD=python3"
74+
) else (
75+
echo %LOG_PREFIX% ERROR: Python not found. 1>&2
76+
echo {"event": "error", "stage": "python", "message": "Python not found"}
77+
exit /b 1
78+
)
79+
)
80+
81+
echo %LOG_PREFIX% Using Python: !PYTHON_CMD! 1>&2
82+
83+
REM ─── Step 3: Create Virtual Environment ───────────────────────────────────
4084

41-
docker build -t %IMAGE_NAME%:%IMAGE_TAG% "%SKILL_DIR%"
85+
set "VENV_DIR=%SKILL_DIR%venv"
86+
echo %LOG_PREFIX% Setting up virtual environment in %VENV_DIR%... 1>&2
87+
echo {"event": "progress", "stage": "build", "message": "Creating Python virtual environment..."}
88+
89+
!PYTHON_CMD! -m venv "%VENV_DIR%"
90+
91+
if not exist "%VENV_DIR%\Scripts\python.exe" (
92+
echo %LOG_PREFIX% ERROR: Failed to create virtual environment. 1>&2
93+
echo {"event": "error", "stage": "build", "message": "Failed to create venv"}
94+
exit /b 1
95+
)
96+
97+
REM ─── Step 4: Install PyCoral & Dependencies ───────────────────────────────
98+
99+
echo %LOG_PREFIX% Installing Python dependencies (including pycoral)... 1>&2
100+
echo {"event": "progress", "stage": "build", "message": "Fetching pycoral specific wheels..."}
101+
102+
"%VENV_DIR%\Scripts\python.exe" -m pip install --upgrade pip >nul 2>&1
103+
104+
"%VENV_DIR%\Scripts\python.exe" -m pip install --extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0
42105
if %errorlevel% neq 0 (
43-
echo %LOG_PREFIX% ERROR: Docker build failed 1>&2
44-
echo {"event": "error", "stage": "build", "message": "Docker image build failed"}
106+
echo %LOG_PREFIX% WARNING: pip install pycoral failed. Will attempt to install standard requirements anyway. 1>&2
107+
)
108+
109+
"%VENV_DIR%\Scripts\python.exe" -m pip install -r "%SKILL_DIR%requirements.txt"
110+
if %errorlevel% neq 0 (
111+
echo %LOG_PREFIX% ERROR: Failed to install Python dependencies. 1>&2
112+
echo {"event": "error", "stage": "build", "message": "pip install failed"}
45113
exit /b 1
46114
)
47115

48-
echo {"event": "progress", "stage": "build", "message": "Docker image ready"}
116+
echo %LOG_PREFIX% Dependencies installed successfully. 1>&2
117+
118+
REM ─── Step 5: Probe for Edge TPU devices ────────────────────────────────────
119+
120+
echo %LOG_PREFIX% Probing for Edge TPU devices natively... 1>&2
121+
echo {"event": "progress", "stage": "probe", "message": "Checking for physical Edge TPU..."}
49122

50-
REM ─── Step 3: Probe for Edge TPU ──────────────────────────────────────────
123+
set "TPU_FOUND=false"
124+
set "TPU_COUNT=?"
51125

52-
echo %LOG_PREFIX% Probing for Edge TPU devices... 1>&2
53-
echo {"event": "progress", "stage": "probe", "message": "Checking for Edge TPU devices..."}
126+
for /f "delims=" %%I in ('"%VENV_DIR%\Scripts\python.exe" "%SKILL_DIR%scripts\tpu_probe.py" 2^>nul') do (
127+
set "PROBE_OUTPUT=%%I"
128+
)
54129

55-
docker run --rm --privileged %IMAGE_NAME%:%IMAGE_TAG% python3 scripts/tpu_probe.py >nul 2>&1
130+
echo !PROBE_OUTPUT! | findstr /C:"\"available\": true" >nul
56131
if %errorlevel% equ 0 (
57-
echo %LOG_PREFIX% Edge TPU detected 1>&2
58-
echo {"event": "progress", "stage": "probe", "message": "Edge TPU detected"}
132+
set "TPU_FOUND=true"
133+
REM Approximate counts natively
134+
echo {"event": "progress", "stage": "probe", "message": "Edge TPU device natively registered"}
59135
) else (
60-
echo %LOG_PREFIX% WARNING: No Edge TPU detected - CPU fallback 1>&2
61-
echo {"event": "progress", "stage": "probe", "message": "No Edge TPU detected - CPU fallback"}
136+
echo {"event": "progress", "stage": "probe", "message": "No Edge TPU detected -- CPU fallback available"}
62137
)
63138

64-
echo {"event": "complete", "status": "success", "message": "Coral TPU skill installed"}
139+
REM ─── Step 6: Complete ──────────────────────────────────────────────────────
65140

66-
echo %LOG_PREFIX% Done! 1>&2
67-
exit /b 0
141+
if "!TPU_FOUND!"=="true" (
142+
echo {"event": "complete", "status": "success", "tpu_found": true, "message": "Native Coral TPU skill installed -- Edge TPU ready"}
143+
exit /b 0
144+
) else (
145+
echo {"event": "complete", "status": "partial", "tpu_found": false, "message": "Native Coral TPU skill installed -- no TPU detected (CPU fallback)"}
146+
exit /b 2
147+
)

0 commit comments

Comments
 (0)