PhysicalWM / 4dcodebench /resim /run_ablation_b07.sh
Ravenveil's picture
backup 03_4dcodebench 2026-11-08 10:10:50
42afafb verified
Raw History Blame Contribute Delete
2.78 kB
#!/bin/bash
# 2x2 ablation on B_07 (4DCodeBench cloth case): agent prior (A) x NeuIDO fit (B)
# A0B0: default card (no agent reasoning, no fitting) -> baseline
# A1B0: agent prior card (material/fall reasoning, no fit)
# A0B1: NeuIDO-style closed-loop fit from neutral start (default center)
# A1B1: NeuIDO-style fit seeded by the agent prior card (interaction)
# Full render (32 samples) for every arm. GPUs 4-7 only.
set -e
export LANG=en_US.UTF-8 PYTHONUTF8=1
cd ~/jiayin/4dcodebench
PY=~/miniconda3/envs/ovow-motion/bin/python
BL=~/jiayin/blender/blender
W=work/B_07/world
BASE=work/B_07/ablation
mkdir -p $BASE
echo "=== [0/6] cards ==="
$PY resim/agent_card.py --world $W --out work/B_07/agent_card.json
test -f work/B_07/fit/best_card.json || { echo "global fit missing"; exit 1; }
render () { # render <outdir> <density> <bending> <air_damp>
local OUT=$1 D=$2 BE=$3 AI=$4
if [ -f "$OUT/sim.mp4" ] && [ $(stat -c %s "$OUT/sim.mp4") -gt 100000 ]; then
echo "--- $OUT already done, skip"; return 0
fi
rm -rf "$OUT"
mkdir -p "$OUT"
echo "--- rendering $OUT (d=$D b=$BE a=$AI)"
CUDA_VISIBLE_DEVICES=$GPU $BL --background --python resim/resim_cloth_blender.py -- \
--world $W --out "$OUT" --density $D --bending $BE --air_damp $AI --samples 32 \
> "$OUT/blender.log" 2>&1
test -f "$OUT/sim.mp4" && [ $(stat -c %s "$OUT/sim.mp4") -gt 100000 ]
}
# ---------- A0B0: default ----------
GPU=4
echo "=== [1/6] A0B0 default ==="
render $BASE/a0b0 0.35 0.02 1.0
# ---------- A1B0: agent prior ----------
echo "=== [2/6] A1B0 agent prior ==="
GPU=5 render $BASE/a1b0 0.35 0.02 1.0 # same card, produced by agent reasoning
cp work/B_07/agent_card.json $BASE/a1b0/params_src.json || true
# ---------- A0B1: NeuIDO fit from neutral start (already fitted globally) ----------
echo "=== [3/6] A0B1 neuido fit (neutral) ==="
read D BE AI <<< $($PY -c "import json;c=json.load(open('work/B_07/fit/best_card.json'));print(c['density'],c['bending'],c['air_damp'])")
GPU=6 render $BASE/a0b1 $D $BE $AI
cp work/B_07/fit/best_card.json $BASE/a0b1/params_src.json
# ---------- A1B1: local refit seeded by agent prior ----------
echo "=== [4/6] A1B1 local refit around agent card ==="
if [ ! -f work/B_07/fit_agent/best_card.json ]; then
$PY resim/fit_params_neuido.py --world $W --out work/B_07/fit_agent \
--trials 10 --parallel 3 --gpus 4,5,6 \
--center work/B_07/agent_card.json --sigma 0.12,0.35,0.25 \
> work/B_07/fit_agent_main.log 2>&1
fi
read D BE AI <<< $($PY -c "import json;c=json.load(open('work/B_07/fit_agent/best_card.json'));print(c['density'],c['bending'],c['air_damp'])")
GPU=7 render $BASE/a1b1 $D $BE $AI
cp work/B_07/fit_agent/best_card.json $BASE/a1b1/params_src.json
echo "=== ALL ABLATION ROLLOUTS DONE ==="