Skip to content

Commit 9c59788

Browse files
committed
fix: add model download step to Coral TPU deploy.sh
The skill crashed with 'No Edge TPU model found' because deploy.sh never downloaded a .tflite model. Now downloads SSD MobileNet V2 (Edge TPU compiled) from google-coral/test_data during deployment, plus a CPU-only fallback variant.
1 parent 91bd79d commit 9c59788

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

  • skills/detection/yolo-detection-2026-coral-tpu

skills/detection/yolo-detection-2026-coral-tpu/deploy.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,40 @@ emit '{"event": "progress", "stage": "install", "message": "Installing ai-edge-l
8888
log "Python dependencies installed"
8989
emit '{"event": "progress", "stage": "install", "message": "Dependencies installed"}'
9090

91+
# ─── Step 3b: Download Edge TPU model if not present ─────────────────────────
92+
93+
MODEL_DIR="$SKILL_DIR/models"
94+
mkdir -p "$MODEL_DIR"
95+
96+
if ! ls "$MODEL_DIR"/*.tflite 1>/dev/null 2>&1; then
97+
log "No .tflite model found — downloading default EfficientDet-Lite0 Edge TPU model..."
98+
emit '{"event": "progress", "stage": "model", "message": "Downloading Edge TPU detection model..."}'
99+
100+
# EfficientDet-Lite0 — 320x320 INT8, compiled for Edge TPU
101+
# Source: https://coral.ai/models/object-detection/
102+
MODEL_URL="https://raw.githubusercontent.com/google-coral/test_data/master/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite"
103+
LABELS_URL="https://raw.githubusercontent.com/google-coral/test_data/master/coco_labels.txt"
104+
105+
if curl -fSL "$MODEL_URL" -o "$MODEL_DIR/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite" 2>&1; then
106+
log "Model downloaded: ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite"
107+
else
108+
log "ERROR: Failed to download Edge TPU model"
109+
emit '{"event": "error", "stage": "model", "message": "Failed to download model"}'
110+
exit 1
111+
fi
112+
113+
# Also download the CPU-only variant for fallback
114+
CPU_MODEL_URL="https://raw.githubusercontent.com/google-coral/test_data/master/ssd_mobilenet_v2_coco_quant_postprocess.tflite"
115+
curl -fSL "$CPU_MODEL_URL" -o "$MODEL_DIR/ssd_mobilenet_v2_coco_quant_postprocess.tflite" 2>&1 || true
116+
117+
# Download labels
118+
curl -fSL "$LABELS_URL" -o "$MODEL_DIR/coco_labels.txt" 2>&1 || true
119+
120+
emit '{"event": "progress", "stage": "model", "message": "Model downloaded ✓"}'
121+
else
122+
log "Model already present in $MODEL_DIR"
123+
fi
124+
91125
# ─── Step 4: Check libedgetpu (platform-specific) ───────────────────────────
92126

93127
log "Checking for libedgetpu hardware driver..."

0 commit comments

Comments
 (0)