Bundle TFLite model in repo, remove download script
The original TF model zoo URL was dead (403). Model sourced from google-coral/test_data instead and checked in directly at 6MB. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -31,6 +31,3 @@ Thumbs.db
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
# ML model binaries (downloaded during setup)
|
||||
*.tflite
|
||||
|
||||
@@ -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!"
|
||||
BIN
server/models/ssd_mobilenet_v2_coco_quant_postprocess.tflite
Normal file
BIN
server/models/ssd_mobilenet_v2_coco_quant_postprocess.tflite
Normal file
Binary file not shown.
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user