temp / FlowCache /FlowCache4MAGI-1-dev6-adaptive /tools /run_compare_dev4_dev6.sh
Cccccz's picture
Add files using upload-large-folder tool
d2b26ce verified
Raw
History Blame Contribute Delete
3.66 kB
#!/usr/bin/env bash
# Compare dev4 fixed tau vs dev6 adaptive tau
set -euo pipefail
DEV4="$(cd "$(dirname "$0")/../../FlowCache4MAGI-1-dev4-detail" && pwd)"
DEV6="$(cd "$(dirname "$0")/.." && pwd)"
DEV3="$(cd "$DEV6/../FlowCache4MAGI-1-dev3-motion" && pwd)"
FRAMES="${FRAMES:-120}"
PROMPT="${PROMPT:-a woman dancing.}"
CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}"
RUN_TAG="${RUN_TAG:-$(date +%Y%m%d_%H%M%S)}"
OUT_ROOT="${OUT_ROOT:-$DEV6/outputs/compare_dev4_dev6_$RUN_TAG}"
mkdir -p "$OUT_ROOT"
BASELINE_VIDEO="${BASELINE_VIDEO:-$DEV6/../FlowCache4MAGI-1/outputs/a_woman_dancing_2026-05-19_09-49-14/output_2026-05-19_09-49-14.mp4}"
if [ -z "${CONDA_DEFAULT_ENV:-}" ] || [ "${CONDA_DEFAULT_ENV}" != "magi" ]; then
# shellcheck disable=SC1091
source "${HOME}/miniforge3/etc/profile.d/conda.sh" 2>/dev/null || source "${HOME}/anaconda3/etc/profile.d/conda.sh"
conda activate magi
fi
export MASTER_ADDR=localhost
export CUDA_VISIBLE_DEVICES
RUNTIME_CFG="$OUT_ROOT/runtime_${FRAMES}f.json"
python3 - "$RUNTIME_CFG" "$FRAMES" <<'PY'
import json
import sys
dst, frames = sys.argv[1], int(sys.argv[2])
src = "/home/dyvm6xra/dyvm6xrauser11/workspace/cz/FlowCache/FlowCache4MAGI-1-dev6-adaptive/config/single_run/flowcache_t2v.json"
with open(src) as f:
cfg = json.load(f)
cfg["runtime_config"]["num_frames"] = frames
with open(dst, "w") as f:
json.dump(cfg, f, indent=4)
PY
run_dev4() {
local run_dir="$OUT_ROOT/dev4_fixed"
mkdir -p "$run_dir"
local ts="${RUN_TAG}_dev4"
export RUN_DIR="$run_dir" RUN_ID="$ts" PROMPT="$PROMPT"
export MOTIONDETAIL_CONFIG="yaml_config/single_run/motiondetail_config_best.yaml"
export CONFIG_FILE="$RUNTIME_CFG"
export OUTPUT_PATH="$run_dir/output_${ts}.mp4"
export METRIC_JSON="$run_dir/metric_${ts}.json"
export LOG_FILE="$run_dir/infer_${ts}.log"
export PYTHONPATH="${DEV4}:${DEV3}:${PYTHONPATH:-}"
echo "=== dev4 fixed tau (${FRAMES}f) ==="
bash "$DEV4/scripts/single_run/motiondetail_t2v.sh"
}
run_dev6() {
local run_dir="$OUT_ROOT/dev6_adaptive"
mkdir -p "$run_dir"
local ts="${RUN_TAG}_dev6"
export RUN_DIR="$run_dir" RUN_ID="$ts" PROMPT="$PROMPT"
export ADAPTIVE_CONFIG="yaml_config/single_run/adaptive_config_best.yaml"
export CONFIG_FILE="$RUNTIME_CFG"
export OUTPUT_PATH="$run_dir/output_${ts}.mp4"
export METRIC_JSON="$run_dir/metric_${ts}.json"
export LOG_FILE="$run_dir/infer_${ts}.log"
export PYTHONPATH="${DEV6}:${DEV4}:${DEV3}:${PYTHONPATH:-}"
echo "=== dev6 adaptive tau (${FRAMES}f) ==="
bash "$DEV6/scripts/single_run/adaptive_t2v.sh"
}
run_dev4
run_dev6
REPORT="$OUT_ROOT/report.md"
{
echo "# dev4 fixed vs dev6 adaptive (${FRAMES}f)"
echo
echo "| variant | PSNR (dB) | SSIM | reuse (%) | peak (GB) |"
echo "|---|---:|---:|---:|---:|"
} > "$REPORT"
for label in dev4_fixed dev6_adaptive; do
suffix="dev4"
[ "$label" = "dev6_adaptive" ] && suffix="dev6"
ts="${RUN_TAG}_${suffix}"
video="$OUT_ROOT/$label/output_${ts}.mp4"
log="$OUT_ROOT/$label/infer_${ts}.log"
metric="$OUT_ROOT/$label/metric_${ts}.json"
eval_out="$(python3 "$DEV3/tools/eval_run.py" \
--baseline "$BASELINE_VIDEO" \
--generated "$video" \
--log "$log" \
--metric "$metric")"
psnr="$(echo "$eval_out" | sed -n 's/^PSNR=//p')"
ssim="$(echo "$eval_out" | sed -n 's/^SSIM=//p')"
reuse="$(echo "$eval_out" | sed -n 's/^REUSE=//p')"
peak="$(echo "$eval_out" | sed -n 's/^PEAK=//p')"
echo "| $label | $psnr | $ssim | $reuse | $peak |" >> "$REPORT"
echo "$label: $eval_out"
done
echo
echo "Report: $REPORT"
cat "$REPORT"