Skip to content

ReShot — copy the shot, not the actors. Video → depth map, OpenPose skeleton or canny lines for Seedance 2.0/2.5 reference video, MiniMax H3 Fun ControlNet and Wan VACE. Apache-2.0. Open-sourced by Maosika 猫斯卡 (www.maosika.com), the AI short-drama production system.

0.3.3: memory estimate fitted on six RTX 4090 runs (2.0 GiB base + 20 B/pixel-frame)

wangfeng008dc526db21
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ae9d4b..33bcb35 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 0.3.3 — 2026-09-12
+- Memory estimate is now a measured line, not a guess: peak RSS = 2.0 GiB + 20 B × frames ×
+ processing pixels (fitted on six RTX 4090 runs, base 1.73 GiB / slope 16.9 B, residual
+ ≤ 0.05 GiB, padded ~15 %). The old flat 32 B/pixel-frame over-refused long clips and
+ under-estimated short ones; `--max-frames` suggestions now account for the base.
+- Measured on the same runs: 61–62 ms/frame on a 4090 for clips ≥ 190 frames (77–92 ms/frame
+ for very short clips, where model load and the first window dominate).
+
## 0.3.2 — 2026-09-12
- **Fix: `--max-res` no longer lowers the inference resolution.** It capped the processing
size too, so `--max-res 320` fed the model a thumbnail; inference now always runs at model
diff --git a/README.md b/README.md
index 0f5fa10..0884914 100644
--- a/README.md
+++ b/README.md
@@ -124,7 +124,7 @@ Three details make the output something a video model will actually follow:
- **Frames picked by timestamp.** 30 fps → 24 fps really is 24; nothing is duplicated or dropped in a pattern the model could learn.
- **Cropped, never padded.** Frame size is trimmed to the model's grid. A black border would read as a far wall.
-The model is Video Depth Anything Small (ByteDance, CVPR 2025). It works on overlapping 32-frame windows and aligns them, so depth doesn't jitter between frames. It needs about 4 GB of RAM for a 720p clip and refuses up front if a clip won't fit. A `fake` backend runs the whole pipeline without a model for your own tests. Errors that are yours to fix are `ReshotError` subclasses with an exit code and a concrete fix in the message.
+The model is Video Depth Anything Small (ByteDance, CVPR 2025). It works on overlapping 32-frame windows and aligns them, so depth doesn't jitter between frames. A 12-second 720p clip peaks at 3.9 GB of host RAM (measured; the estimate the tool shows before starting is a fitted line, within 0.05 GB of measurements) and it refuses up front if a clip won't fit. A `fake` backend runs the whole pipeline without a model for your own tests. Errors that are yours to fix are `ReshotError` subclasses with an exit code and a concrete fix in the message.
## License
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 60bc66e..8ad99cc 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -124,7 +124,7 @@ run(RunConfig(input=Path("参考片.mp4"), output=Path("深度图.mp4"), target=
- **按时间戳选帧。** 30 fps 转 24 fps 就真的是 24,不会以某种规律重复或丢帧让模型学了去。
- **只裁不补。** 尺寸裁到模型要的网格上,绝不补黑边——黑边会被当成远处的墙。
-模型是 Video Depth Anything Small(字节跳动,CVPR 2025),以 32 帧为一个窗口重叠推理并对齐,深度不会一帧一帧地跳。720p 一段片约需 4 GB 内存,放不下会在开始之前拒绝。`fake` 后端不加载模型就能跑完整条流水线,方便你写测试。属于「用户该修」的错误都是 `ReshotError` 的子类,带退出码和具体的修法。
+模型是 Video Depth Anything Small(字节跳动,CVPR 2025),以 32 帧为一个窗口重叠推理并对齐,深度不会一帧一帧地跳。12 秒 720p 一段片峰值占 3.9 GB 内存(实测;开跑前显示的估算是拟合出来的直线,与实测误差 0.05 GB 以内),放不下会在开始之前拒绝。`fake` 后端不加载模型就能跑完整条流水线,方便你写测试。属于「用户该修」的错误都是 `ReshotError` 的子类,带退出码和具体的修法。
## 协议
diff --git a/demo/requirements.txt b/demo/requirements.txt
index 38ed5a0..9eb0827 100644
--- a/demo/requirements.txt
+++ b/demo/requirements.txt
@@ -1,5 +1,5 @@
--extra-index-url https://download.pytorch.org/whl/cpu
torch
torchvision
-reshot[ffmpeg] @ git+https://github.com/maosika-ai/[email protected]
+reshot[ffmpeg] @ git+https://github.com/maosika-ai/[email protected]
gradio>=4.0
diff --git a/reshot/_version.py b/reshot/_version.py
index f9aa3e1..e19434e 100644
--- a/reshot/_version.py
+++ b/reshot/_version.py
@@ -1 +1 @@
-__version__ = "0.3.2"
+__version__ = "0.3.3"
diff --git a/reshot/planning.py b/reshot/planning.py
index 85cdbef..836fd6f 100644
--- a/reshot/planning.py
+++ b/reshot/planning.py
@@ -5,18 +5,22 @@ Why this module exists: on 2026-09-11 a 12 s 736×1280 clip took the reference p
20.8 GB of RSS on a 32 GB Mac and the OS killed the desktop. The model itself only ever
sees a 518 px short side; everything above that was full-resolution float32 depth kept
for every frame. So: infer at model resolution, estimate memory up front, refuse loudly
-instead of swapping the machine to death.
+instead of swapping the machine to death. The estimate is a measured line, not a guess.
"""
from __future__ import annotations
import os
-#: Host bytes per (frame × pixel at processing resolution). Measured on the reference
-#: pipeline (RSS 8.2 GB / (294 frames × 1280 × 736 px) ≈ 30 B). Kept deliberately
-#: conservative until re-measured with the model-resolution path; recalibrate from
-#: `metrics.jsonl` of a real run, not by guessing.
-HOST_BYTES_PER_PIXEL_FRAME = 32.0
+#: Peak host RSS = HOST_BASE_BYTES + HOST_BYTES_PER_PIXEL_FRAME × frames × processing pixels.
+#: Fitted on 2026-09-12 (reshot 0.3.2, RTX 4090, CUDA 12.8, torch 2.8, Small model) over six
+#: runs spanning 22M–138M pixel·frames: base 1.73 GiB, slope 16.9 B, max residual 0.05 GiB
+#: (docs/ops/depthcat-autodl/runs/calib_20260912_145501 in the Maosika repo). The base is
+#: torch + CUDA context + the model; the slope is RGB frames (3 B) + the model's float depth
+#: list and its aligned copy (2 × 4 B) + grey output (1 B) + transient window tensors.
+#: Both are padded ~15 % so a laptop with a browser open is still refused before it swaps.
+HOST_BASE_BYTES = int(2.0 * 2**30)
+HOST_BYTES_PER_PIXEL_FRAME = 20.0
#: Refuse when the estimate exceeds this share of physical RAM. Half, not 90 %: the
#: OS, the browser and the GPU driver (unified memory on Apple Silicon) all need room.
@@ -37,7 +41,8 @@ def processing_max_res(width: int, height: int, input_size: int = 518) -> int:
def estimate_host_bytes(frames: int, proc_w: int, proc_h: int) -> int:
- return int(frames * proc_w * proc_h * HOST_BYTES_PER_PIXEL_FRAME)
+ """Peak host RSS for a run: fixed base plus a per-pixel-frame slope (see constants)."""
+ return HOST_BASE_BYTES + int(frames * proc_w * proc_h * HOST_BYTES_PER_PIXEL_FRAME)
def physical_ram_bytes() -> int:
@@ -63,12 +68,12 @@ def memory_verdict(frames: int, proc_w: int, proc_h: int, ram_bytes: int | None
ram = ram_bytes if ram_bytes is not None else physical_ram_bytes()
budget = int(ram * HOST_RAM_BUDGET_RATIO)
est = estimate_host_bytes(frames, proc_w, proc_h)
- per_frame = max(1, estimate_host_bytes(1, proc_w, proc_h))
+ per_frame = max(1, estimate_host_bytes(1, proc_w, proc_h) - HOST_BASE_BYTES)
return {
"estimate": est,
"budget": budget,
"ok": est <= budget,
- "max_frames_ok": max(1, budget // per_frame),
+ "max_frames_ok": max(1, (budget - HOST_BASE_BYTES) // per_frame),
}
diff --git a/tests/test_planning.py b/tests/test_planning.py
index 3b09d10..8e4feb5 100644
--- a/tests/test_planning.py
+++ b/tests/test_planning.py
@@ -18,9 +18,20 @@ def test_processing_res_never_upscales():
assert processing_max_res(400, 300) == 400
-def test_estimate_scales_with_pixels_and_frames():
- assert estimate_host_bytes(2, 100, 100) == 2 * estimate_host_bytes(1, 100, 100)
- assert estimate_host_bytes(1, 200, 100) == 2 * estimate_host_bytes(1, 100, 100)
+def test_estimate_is_base_plus_linear_in_pixel_frames():
+ base = estimate_host_bytes(0, 100, 100)
+ one = estimate_host_bytes(1, 100, 100) - base
+ assert estimate_host_bytes(2, 100, 100) - base == 2 * one
+ assert estimate_host_bytes(1, 200, 100) - base == 2 * one
+
+
+def test_estimate_matches_measured_4090_runs():
+ """Calibration points from 2026-09-12 (see planning.py); the padded model must sit
+ above every measurement but within ~25 % of it."""
+ measured = [(48, 900, 518, 2.12), (294, 900, 518, 3.90), (96, 864, 496, 2.36), (289, 864, 496, 3.69)]
+ for frames, w, h, gib in measured:
+ est = estimate_host_bytes(frames, w, h) / 2**30
+ assert gib <= est <= gib * 1.25, (frames, w, h, gib, est)
def test_verdict_refuses_over_budget_and_suggests_frames():