Files

41 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Vendor microsoft/Lens upstream into ./lens_source so that `from lens import
# LensPipeline` resolves to the pinned source. v2 README §10 雷:
# "import lens" 必须先于 `LensPipeline.from_pretrained`,因为它注册自定义
# 类到 transformers/diffusers 命名空间。
set -euo pipefail
REPO_URL="${LENS_REPO_URL:-https://github.com/microsoft/Lens.git}"
PIN="${LENS_PIN:-}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
DEST="$HERE/lens_source"
if [ -d "$DEST/.git" ]; then
echo "[fetch_upstream] $DEST exists, pulling..."
git -C "$DEST" fetch --all
else
echo "[fetch_upstream] cloning $REPO_URL -> $DEST"
git clone "$REPO_URL" "$DEST"
fi
if [ -n "$PIN" ]; then
echo "[fetch_upstream] checking out pinned commit $PIN"
git -C "$DEST" checkout "$PIN"
else
echo "[fetch_upstream] staying on default branch (set LENS_PIN=<sha> for reproducibility)"
fi
echo "[fetch_upstream] verifying lens/ package exists ..."
if [ ! -d "$DEST/lens" ]; then
echo "ERROR: $DEST/lens does not exist after clone. Upstream layout may have changed." >&2
ls -la "$DEST" >&2
exit 1
fi
echo "[fetch_upstream] OK — lens_source/lens/ ready"
echo
echo "Next steps:"
echo " 1) bash scripts/install_deps.sh"
echo " 2) hf auth login # if not already, microsoft/Lens-Turbo is gated"
echo " 3) restart ComfyUI"