#!/usr/bin/env bash # Run once after downloading this folder: bash fetch.sh # Downloads Ultralytics' yolo11n.pt (v8.3.0, sha256-checked) where build.sh looks for it. set -euo pipefail cd "$(dirname "$0")" REPO=nnopt-dev/YOLO11n-MLX # The repository's manifest first (Hugging Face counts a download when config.json is requested). curl -fsSL "https://huggingface.co/$REPO/resolve/main/config.json" -o ../config.json sha256_of() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d" " -f1; else shasum -a 256 "$1" | cut -d" " -f1; fi; } get() { # get URL FILE SHA256: download once, check the sha256 if [ -f "$2" ] && [ "$(sha256_of "$2")" = "$3" ]; then return 0; fi mkdir -p "$(dirname "$2")" curl -fL --retry 3 -o "$2.part" "$1" [ "$(sha256_of "$2.part")" = "$3" ] || { echo "fetch.sh: sha256 mismatch for $1" >&2; rm -f "$2.part"; exit 1; } mv "$2.part" "$2" } git_at() { # git_at URL COMMIT DIR: the exact commit, shallow if [ "$(git -C "$3" rev-parse HEAD 2>/dev/null || true)" = "$2" ]; then return 0; fi rm -rf "$3"; mkdir -p "$3" git -C "$3" init -q && git -C "$3" remote add origin "$1" git -C "$3" fetch -q --depth 1 origin "$2" && git -C "$3" -c advice.detachedHead=false checkout -q FETCH_HEAD } get "https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt" \ build/yolo11n.pt 0ebbc80d4a7680d14987a577cd21342b65ecfd94632bd9a8da63ae6417644ee1 echo "fetch.sh: done. Next: bash build.sh, then bash deploy.sh ~/yolo11n-mlx"