diff --git a/.gitignore b/.gitignore index 2cf6e14..6155ad8 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,4 @@ Thumbs.db # Test artifacts .pytest_cache/ .coverage -htmlcov/ - -# ML model binaries (downloaded during setup) -*.tflite +htmlcov/ \ No newline at end of file diff --git a/server/download_model.sh b/server/download_model.sh deleted file mode 100755 index fb1e651..0000000 --- a/server/download_model.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# Download MobileNet V2 SSD (COCO, INT8 quantized) for TFLite -# -# Model: ssd_mobilenet_v2_coco_quant_postprocess.tflite (~6MB) -# Source: TensorFlow Model Zoo -# Classes: 80 COCO object classes -# -# This script is idempotent - skips download if model exists. - -set -e - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -MODEL_DIR="${SCRIPT_DIR}/models" -MODEL_FILE="${MODEL_DIR}/ssd_mobilenet_v2_coco_quant_postprocess.tflite" -ZIP_URL="https://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v2_quantized_300x300_uint8_20200430.zip" -ZIP_FILE="${MODEL_DIR}/model.zip" - -mkdir -p "${MODEL_DIR}" - -if [ -f "${MODEL_FILE}" ]; then - echo "Model already exists: ${MODEL_FILE}" - echo "Size: $(du -h "${MODEL_FILE}" | cut -f1)" - exit 0 -fi - -echo "Downloading MobileNet V2 SSD (quantized)..." -curl -L -o "${ZIP_FILE}" "${ZIP_URL}" - -echo "Extracting model..." -unzip -o "${ZIP_FILE}" -d "${MODEL_DIR}" - -# Clean up zip and extra files -rm -f "${ZIP_FILE}" -rm -f "${MODEL_DIR}/labelmap.txt" # We use our own coco_labels.txt - -if [ -f "${MODEL_FILE}" ]; then - echo "Model downloaded: ${MODEL_FILE}" - echo "Size: $(du -h "${MODEL_FILE}" | cut -f1)" -else - # The zip might extract with a slightly different path - FOUND=$(find "${MODEL_DIR}" -name "*.tflite" -type f | head -1) - if [ -n "${FOUND}" ] && [ "${FOUND}" != "${MODEL_FILE}" ]; then - mv "${FOUND}" "${MODEL_FILE}" - echo "Model downloaded: ${MODEL_FILE}" - echo "Size: $(du -h "${MODEL_FILE}" | cut -f1)" - else - echo "ERROR: Model file not found after extraction" - exit 1 - fi -fi - -# Clean up any extracted subdirectories -find "${MODEL_DIR}" -mindepth 1 -type d -exec rm -rf {} + 2>/dev/null || true - -echo "Done!" diff --git a/server/models/ssd_mobilenet_v2_coco_quant_postprocess.tflite b/server/models/ssd_mobilenet_v2_coco_quant_postprocess.tflite new file mode 100644 index 0000000..28b6bde Binary files /dev/null and b/server/models/ssd_mobilenet_v2_coco_quant_postprocess.tflite differ diff --git a/server/setup.sh b/server/setup.sh index d3d04f7..de4446c 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -73,12 +73,11 @@ cp "${SCRIPT_DIR}/motion.py" "${INSTALL_DIR}/" cp "${SCRIPT_DIR}/detector.py" "${INSTALL_DIR}/" cp "${SCRIPT_DIR}/requirements.txt" "${INSTALL_DIR}/" cp "${SCRIPT_DIR}/generate_cert.sh" "${INSTALL_DIR}/" -cp "${SCRIPT_DIR}/download_model.sh" "${INSTALL_DIR}/" cp "${SCRIPT_DIR}/.env" "${INSTALL_DIR}/" # Copy model files mkdir -p "${INSTALL_DIR}/models" -cp "${SCRIPT_DIR}/models/coco_labels.txt" "${INSTALL_DIR}/models/" +cp "${SCRIPT_DIR}/models/"* "${INSTALL_DIR}/models/" # Create virtual environment echo_info "Creating Python virtual environment..." @@ -95,15 +94,6 @@ pip install -r requirements.txt echo_info "Installing TFLite runtime for object detection..." pip install tflite-runtime 2>/dev/null || echo_warn "tflite-runtime not available for this platform (object detection will be disabled)" -# Download object detection model (if not already present) -if [ -f "${INSTALL_DIR}/models/ssd_mobilenet_v2_coco_quant_postprocess.tflite" ]; then - echo_info "Object detection model already present" -else - echo_info "Downloading object detection model..." - chmod +x "${INSTALL_DIR}/download_model.sh" - cd "${INSTALL_DIR}" && ./download_model.sh -fi - # Generate SSL certificates if not present if [ ! -f ssl/cert.pem ]; then echo_info "Generating SSL certificates..."