-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·89 lines (77 loc) · 3.19 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·89 lines (77 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
#
# Taskmaster one-shot setup.
# Installs BOTH halves of the app:
# 1. Python CV worker -> venv at python/.venv + pip deps from python/requirements.txt
# 2. Electron app -> npm deps in electron/
#
# Usage:
# ./setup.sh
#
# Re-runnable: safe to run again; it reuses an existing venv and npm cache.
# Stop immediately if any command fails, and treat unset vars as errors.
set -euo pipefail
# Always operate relative to this script's own location, no matter where it
# is called from.
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$PROJECT_ROOT"
# ---------------------------------------------------------------------------
# 1. Python CV worker
# ---------------------------------------------------------------------------
echo "==> [1/2] Python CV worker"
# MediaPipe has no wheels for Python 3.13/3.14, so we pin to 3.11 explicitly.
if ! command -v python3.11 >/dev/null 2>&1; then
echo "ERROR: python3.11 not found. Install it (e.g. 'brew install python@3.11') and re-run." >&2
exit 1
fi
# Create the venv only if it does not already exist.
if [ ! -d "python/.venv" ]; then
echo " creating venv at python/.venv (Python 3.11)"
python3.11 -m venv python/.venv
else
echo " reusing existing venv at python/.venv"
fi
# Install dependencies into the venv using its own pip (no need to 'activate').
echo " installing Python dependencies"
python/.venv/bin/pip install --upgrade pip
python/.venv/bin/pip install -r python/requirements.txt
# Download the phone-detection model (YOLOX-S, Apache-2.0). It is gitignored
# (~34 MB), so a fresh clone needs to fetch it once.
PHONE_MODEL="python/models/yolox_s.onnx"
if [ ! -f "$PHONE_MODEL" ]; then
echo " downloading phone-detection model (YOLOX-S)"
mkdir -p python/models
curl -sSL -o "$PHONE_MODEL" \
"https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.onnx"
else
echo " phone-detection model already present"
fi
# Download the gaze model (MediaPipe FaceLandmarker, Apache-2.0). Gitignored
# (~3.6 MB), fetched once on a fresh clone.
GAZE_MODEL="python/models/face_landmarker.task"
if [ ! -f "$GAZE_MODEL" ]; then
echo " downloading gaze model (FaceLandmarker)"
mkdir -p python/models
curl -sSL -o "$GAZE_MODEL" \
"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task"
else
echo " gaze model already present"
fi
# ---------------------------------------------------------------------------
# 2. Electron app
# ---------------------------------------------------------------------------
echo "==> [2/2] Electron app"
if ! command -v npm >/dev/null 2>&1; then
echo "ERROR: npm not found. Install Node.js >= 18 and re-run." >&2
exit 1
fi
echo " installing npm dependencies in electron/"
( cd electron && npm install )
# ---------------------------------------------------------------------------
echo ""
echo "Done. To run the app:"
echo " cd electron && npm run dev"
echo "Electron starts the Python CV worker automatically when detection is needed."
echo ""
echo "To run the CV worker by itself (e.g. for testing):"
echo " cd python && source .venv/bin/activate && python -m uvicorn main:app --port 8765"