diff --git a/.github/workflows/electron-ci.yml b/.github/workflows/electron-ci.yml new file mode 100644 index 0000000..c3f8761 --- /dev/null +++ b/.github/workflows/electron-ci.yml @@ -0,0 +1,41 @@ +name: Electron CI + +on: + push: + paths: + - "electron/**" + - ".github/workflows/electron-ci.yml" + + pull_request: + paths: + - "electron/**" + - ".github/workflows/electron-ci.yml" + +jobs: + electron-checks: + name: Install, link, and build Electron app + runs-on: ubuntu-latest + + defaults: + run: + working-directory: electron + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: electron/package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Run lint + run: npm run lint + + - name: Build Electron renderer + run: npm run build \ No newline at end of file diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml new file mode 100644 index 0000000..49ced8f --- /dev/null +++ b/.github/workflows/python-ci.yml @@ -0,0 +1,55 @@ +name: Python CI + +on: + push: + paths: + - "python/**" + - ".github/workflows/python-ci.yml" + + pull_request: + paths: + - "python/**" + - ".github/workflows/python-ci.yml" + + +jobs: + python-checks: + name: Install and import-check Python CV worker + runs-on: ubuntu-latest + + defaults: + run: + working-directory: python + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + cache: pip + cache-dependency-path: python/requirements.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Check Python imports + run: | + python - <<'PY' + import cv2 + import numpy + import onnxruntime + import fastapi + import uvicorn + import websockets + + print("Python CV dependencies imported successfully") + PY + + - name: Check project modules compile + run: | + python -m compileall . \ No newline at end of file diff --git a/python/.dockerignore b/python/.dockerignore new file mode 100644 index 0000000..f568191 --- /dev/null +++ b/python/.dockerignore @@ -0,0 +1,5 @@ +.venv +__pycache__ +*.pyc +models/*.onnx +models/*.task \ No newline at end of file diff --git a/python/Dockerfile b/python/Dockerfile new file mode 100644 index 0000000..48bb5bf --- /dev/null +++ b/python/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.11-slim + +WORKDIR /app + +# Install system dependencies commonly needed by OpenCV/MediaPipe at runtime +RUN apt-get update && apt-get install -y --no-install-recommends \ + libglib2.0-0 \ + libgl1 \ + libgomp1 \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . + +RUN python -m pip install --upgrade pip \ + && pip install --no-cache-dir -r requirements.txt + +# Download YOLOX-S phone detection model into the image +RUN mkdir -p models && \ + python -c "import urllib.request; urllib.request.urlretrieve('https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.onnx', 'models/yolox_s.onnx')" + +COPY . . + +CMD ["python", "-m", "compileall", "."] \ No newline at end of file diff --git a/python/cv/phone_image_test.py b/python/cv/phone_image_test.py new file mode 100644 index 0000000..445bc48 --- /dev/null +++ b/python/cv/phone_image_test.py @@ -0,0 +1,22 @@ +import sys +import cv2 + +from phone_detector import detect_phone + + +def main(): + if len(sys.argv) < 2: + raise SystemExit("Usage: python cv/phone_image_test.py ") + + image_path = sys.argv[1] + frame = cv2.imread(image_path) + + if frame is None: + raise SystemExit(f"Could not read image: {image_path}") + + result = detect_phone(frame) + print(result) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/python/test_assets/phone_sample.jpg b/python/test_assets/phone_sample.jpg new file mode 100644 index 0000000..ab22cbe Binary files /dev/null and b/python/test_assets/phone_sample.jpg differ diff --git a/python/test_assets/swello-2f_zK0ruzJE-unsplash.jpg b/python/test_assets/swello-2f_zK0ruzJE-unsplash.jpg new file mode 100644 index 0000000..d73851b Binary files /dev/null and b/python/test_assets/swello-2f_zK0ruzJE-unsplash.jpg differ diff --git a/python/test_assets/woman-with-her-head-down-on-the-table-looking-at-phone.jpg b/python/test_assets/woman-with-her-head-down-on-the-table-looking-at-phone.jpg new file mode 100644 index 0000000..4996e01 Binary files /dev/null and b/python/test_assets/woman-with-her-head-down-on-the-table-looking-at-phone.jpg differ