Download scripts/run_nf_reference_score_step_sweep.sh from Lingmin-Ran/SADAE: direct link, hf CLI and curl.
- Browser
- Download file 2.98 kB
-
https://huggingface.co/Lingmin-Ran/SADAE/resolve/main/scripts/run_nf_reference_score_step_sweep.sh
- Command line
-
hf download hf://Lingmin-Ran/SADAE/scripts/run_nf_reference_score_step_sweep.sh
-
curl -L -o run_nf_reference_score_step_sweep.sh https://huggingface.co/Lingmin-Ran/SADAE/resolve/main/scripts/run_nf_reference_score_step_sweep.sh
2.98 kB
| set -uo pipefail | |
| if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then | |
| cat <<'USAGE' | |
| Usage: bash scripts/run_nf_reference_score_step_sweep.sh [STEP_SIZE ...] | |
| Default step sizes: 0.001 0.002 0.005 | |
| Every group edits the same four images (IDs 0, 1, 2, 3 in 0_random_140), | |
| using seed 999, four fixed noise samples, and 50 updates. | |
| Environment overrides: | |
| NF_REF_OUTPUT_ROOT New output root (default: result/nf_reference_score_step_sweep) | |
| NF_REF_NUM_STEPS Updates per image (default: 50) | |
| CUDA_VISIBLE_DEVICES GPU selection (default: 0) | |
| Example: | |
| NF_REF_NUM_STEPS=200 NF_REF_OUTPUT_ROOT=result/nf_reference_score_step_sweep_k200 \ | |
| bash scripts/run_nf_reference_score_step_sweep.sh 0.001 0.002 0.005 0.01 | |
| USAGE | |
| exit 0 | |
| fi | |
| step_sizes=("$@") | |
| if (( ${#step_sizes[@]} == 0 )); then | |
| step_sizes=(0.001 0.002 0.005) | |
| fi | |
| cd "$(dirname "$0")/.." | |
| experiment_root="${NF_REF_OUTPUT_ROOT:-result/nf_reference_score_step_sweep}" | |
| num_steps="${NF_REF_NUM_STEPS:-50}" | |
| if [[ -e "$experiment_root" ]]; then | |
| printf 'Output root already exists; choose a new NF_REF_OUTPUT_ROOT: %s\n' "$experiment_root" >&2 | |
| exit 1 | |
| fi | |
| source /mnt/bn/jiangzhongtao/miniconda3/etc/profile.d/conda.sh | |
| conda activate pvd | |
| python - "$num_steps" "${step_sizes[@]}" <<'PY' | |
| import math | |
| import sys | |
| try: | |
| if int(sys.argv[1]) < 1: | |
| raise ValueError('NF_REF_NUM_STEPS must be a positive integer') | |
| values = [float(value) for value in sys.argv[2:]] | |
| if any(not math.isfinite(value) or value <= 0 for value in values): | |
| raise ValueError('Step sizes must be finite and positive') | |
| if len(set(values)) != len(values): | |
| raise ValueError('Step sizes must be distinct') | |
| except ValueError as error: | |
| sys.exit(str(error)) | |
| PY | |
| export HF_HUB_CACHE="$PWD/ckpts/hf_cache" | |
| export HF_HUB_OFFLINE=1 | |
| export TRANSFORMERS_OFFLINE=1 | |
| export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}" | |
| mkdir -p "$experiment_root" | |
| failed_steps=() | |
| for step_size in "${step_sizes[@]}"; do | |
| group="step_${step_size}" | |
| printf '\nRunning step_size=%s, num_steps=%s, images=4\n' "$step_size" "$num_steps" | |
| if python -u scripts/nf_reference_score_editing.py \ | |
| --category 0_random_140 \ | |
| --image-id 0 --image-id 1 --image-id 2 --image-id 3 \ | |
| --max-samples 4 \ | |
| --seed 999 --vae-latent mean \ | |
| --num-noise-samples 4 --noise-batch-size 1 \ | |
| --num-steps "$num_steps" --step-size "$step_size" \ | |
| --output-dir "$experiment_root/$group" \ | |
| 2>&1 | tee "$experiment_root/$group.log"; then | |
| printf 'Completed step_size=%s\n' "$step_size" | |
| else | |
| failed_steps+=("$step_size") | |
| printf 'Failed step_size=%s; see %s/%s.log\n' "$step_size" "$experiment_root" "$group" >&2 | |
| fi | |
| done | |
| printf '\nSweep finished; output=%s\n' "$experiment_root" | |
| sweep_status=0 | |
| if (( ${#failed_steps[@]} > 0 )); then | |
| printf 'Failed step sizes: %s\n' "${failed_steps[*]}" >&2 | |
| sweep_status=1 | |
| fi | |
| bash /mnt/bn/jiangzhongtao/lingmin/ml-starflow/scripts/zhanka.sh | |
| exit "$sweep_status" | |