clusterflux / deploy.sh
rayh's picture
Deploy latest YOLO model and app (version 20250422.7)
8fd2d1a
raw
history blame
1.17 kB
#!/bin/bash
# Usage: ./deploy.sh <path_to_latest_yolo_train_dir> <hf_space_git_url>
# Example: ./deploy.sh ../yolo-output/models/20250422.7/ https://huggingface.co/spaces/<user>/<space_name>.git
set -e
if [ $# -lt 1 ]; then
echo "Usage: $0 <path_to_latest_yolo_train_dir>"
exit 1
fi
MODEL_DIR=$1
[email protected]:spaces/rayh/clusterflux
MODEL_SERVER_DIR=$(dirname "$0")
WEIGHTS_SRC="$MODEL_DIR/train/weights/best.pt"
WEIGHTS_DST="$MODEL_SERVER_DIR/weights/best.pt"
# Step 1: Copy model weights
mkdir -p "$MODEL_SERVER_DIR/weights"
cp "$WEIGHTS_SRC" "$WEIGHTS_DST"
echo "Copied model weights from $WEIGHTS_SRC to $WEIGHTS_DST"
# Step 2: Extract version (last part of model dir)
VERSION=$(basename "$MODEL_DIR")
echo "$VERSION" > "$MODEL_SERVER_DIR/VERSION"
echo "Set VERSION to $VERSION"
# Step 3: Deploy to Hugging Face Spaces
echo "Pushing to Hugging Face Space..."
cd "$MODEL_SERVER_DIR"
if [ ! -d .git ]; then
git init
git remote add origin "$HF_SPACE_URL"
fi
git add .
git commit -m "Deploy latest YOLO model and app (version $VERSION)" || echo "Nothing to commit"
git branch -M main
git push -u origin main --force
echo "Deployment complete."