vidgod/bin/vg-interp
type-two 8c84243b61 phase 2: vg-remove (ProPainter), vg-interp (RIFE), vg-cutie, farm ops, zoo mirror
- vg-remove: object/logo/watermark removal via ProPainter on MPS; static --box,
  SAM2-tracked --point for moving objects, or user --mask. Output always scaled
  back to source dims (imageio macro-block-pads ProPainter output).
- vg-interp: RIFE frame interpolation via rife-ncnn-vulkan (universal binary,
  native Metal/MoltenVK, rife-v4.6); smooth (fps x N) or --slowmo.
- vg-cutie: Cutie interactive segmentation GUI launcher (local GUI session).
- setup/fetch_phase2.sh: idempotent clones + weights + deps + patches.
- patches: propainter-cv2-reader (torchvision >= 0.23 removed read_video),
  cutie-device (get_default_model hard-coded .cuda(); now cuda->mps->cpu).
- smoke_test.sh: adds the RIFE lane (skips when not fetched).
- Farm: vidgod_roto/vidgod_index operators live in MODELBEAST (8965d22),
  verified from JING5; weights mirrored to NAS modelzoo/vidgod-weights.

All lanes verified on ultra 2026-08-24: de-logo reconstruction eyeballed clean,
24->48fps interp, Cutie headless propagation PASS, smoke test 4/4.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 15:42:52 +10:00

66 lines
2.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/zsh
# vg-interp — RIFE frame interpolation (rife-ncnn-vulkan, Metal via MoltenVK).
# Usage: vg-interp CLIP [--factor 2|4] [--slowmo] [--out FILE] [--model rife-v4.6]
# default: smooth motion (fps × factor, audio kept)
# --slowmo: same fps, clip runs factor× longer (audio dropped)
# Output: ProRes LT .mov next to the input (CLIP_interp.mov / CLIP_slowmo.mov)
export PATH=/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
set -u
VG="$(cd "$(dirname "$0")/.." && pwd)"
RIFE="$VG/tools/rife/rife-ncnn-vulkan"
[[ -x "$RIFE" ]] || { echo "rife not installed — run setup/fetch_phase2.sh" >&2; exit 1; }
IN="${1:?usage: vg-interp CLIP [--factor N] [--slowmo] [--out FILE] [--model NAME]}"
shift
FACTOR=2; SLOWMO=0; OUT=""; MODEL="rife-v4.6"
while [[ $# -gt 0 ]]; do
case "$1" in
--factor) FACTOR="$2"; shift 2 ;;
--slowmo) SLOWMO=1; shift ;;
--out) OUT="$2"; shift 2 ;;
--model) MODEL="$2"; shift 2 ;;
*) echo "unknown arg: $1" >&2; exit 1 ;;
esac
done
IN="${IN:A}"
[[ -f "$IN" ]] || { echo "no such file: $IN" >&2; exit 1; }
fps=$(ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of csv=p=0 "$IN")
fps_num="${fps%%/*}"; fps_den="${fps##*/}"
in_fps=$(( fps_num * 1.0 / fps_den ))
W=$(mktemp -d "${TMPDIR:-/tmp}/vginterp.XXXXXX")
trap "rm -rf $W" EXIT
mkdir -p "$W/in" "$W/out"
echo "extracting frames ..."
ffmpeg -hide_banner -loglevel error -y -i "$IN" "$W/in/%08d.png" </dev/null
n_in=$(ls "$W/in" | wc -l | tr -d " ")
n_out=$(( n_in * FACTOR ))
echo "$n_in frames in -> $n_out frames (${MODEL})"
"$RIFE" -i "$W/in" -o "$W/out" -m "$VG/tools/rife/$MODEL" -n "$n_out" -f "%08d.png" || exit 1
n_got=$(ls "$W/out" | wc -l | tr -d " ")
echo "rife produced $n_got frames"
if [[ $SLOWMO -eq 1 ]]; then
out_fps=$in_fps
DEF="${IN%.*}_slowmo.mov"
else
out_fps=$(( in_fps * FACTOR ))
DEF="${IN%.*}_interp.mov"
fi
OUT="${OUT:-$DEF}"
out_fps=$(printf "%g" "$out_fps")
echo "encoding ProRes at ${out_fps}fps ..."
if [[ $SLOWMO -eq 1 ]]; then
ffmpeg -hide_banner -loglevel error -y -framerate "$out_fps" -i "$W/out/%08d.png" \
-c:v prores_ks -profile:v 1 -pix_fmt yuv422p10le "$OUT" </dev/null
else
ffmpeg -hide_banner -loglevel error -y -framerate "$out_fps" -i "$W/out/%08d.png" -i "$IN" \
-map 0:v:0 -map '1:a:0?' -c:v prores_ks -profile:v 1 -pix_fmt yuv422p10le \
-c:a pcm_s16le -shortest "$OUT" </dev/null
fi
echo "done: $OUT"