all lessons / computer_vision / 16 · video lesson 16 / 19

Video and temporal models

视频与时序模型

Lesson 15 closed our tour of single still images: CLIP aligned one frozen frame to text, and the VLM stack (vision encoder → projector → LLM) could caption or answer questions about a photograph. But the photograph never moved. Lesson 15 closed on exactly that promise — static-image representations are done, and a video is just images plus motion — so this lesson makes good on it by adding the time axis. The real world is a stream — an action is not a pixel pattern, it is a pixel pattern changing over time — and that one extra dimension brings a new free variable that quietly decides everything: which frames the model even gets to see.

第 15 课结束了我们对单张静止图像的巡礼:CLIP 把一帧冻结的画面与文本对齐,而 VLM 技术栈(视觉编码器 → 投影器 → LLM)能够对一张照片做图像描述或回答问题。但照片从不运动。第 15 课正是以这个承诺收尾的——静态图像的表示已经讲完,而视频不过是图像加上运动——所以本课就通过加上时间轴来兑现它。真实世界是一条数据流——一个动作不是一种像素模式,而是一种随时间变化的像素模式——而这多出来的一个维度带来了一个悄悄决定一切的新自由变量:模型究竟能看到哪些帧。

What we are standing on. This lesson borrows tools earned earlier rather than rebuilding them: lesson 02's spatial gradients and the Nyquist/aliasing sampling limit (now applied to time, not space), lesson 06's convolution and its FLOP accounting and receptive field, lesson 07's train/serve split discipline (which a video makes far easier to violate), lesson 09's IoU and mAP, and lesson 13's self-attention with its O(n²) cost. Keep those five in reach; the new material is just the time axis layered on top.

我们所站立的基础。本课借用此前已经掌握的工具,而不是重新搭建它们:第 02 课的空间梯度与奈奎斯特/混叠采样限(现在应用于时间,而非空间)、第 06 课的卷积及其 FLOP 计算和感受野、第 07 课的训练/服务划分纪律(视频让它更容易被违反)、第 09 课的 IoUmAP,以及第 13 课带有 O(n²) 开销的自注意力。把这五样东西放在手边;新的内容只是叠加在其上的时间轴而已。

The plan计划
Four moves. (1) Treat frame sampling — rate, stride, clip length — as a modeling decision, not a loader detail, and count the data it throws away. (2) Pin down what optical flow is numerically: the brightness-constancy assumption and the one scalar equation it yields. (3) Compare the three ways to fuse time — 3D conv, two-stream, temporal attention — and do the FLOP arithmetic that explains why 3D conv is expensive. (4) Put it in production: streaming latency budgets, causal vs offline models, and the temporal metrics (clip vs video accuracy, mAP for temporal localization) the index promised. 四步走。(1) 把帧采样——帧率、步幅、片段长度——当成一个建模决策,而不是数据加载器的细节,并算清它丢掉了多少数据。(2) 从数值上钉死光流什么:亮度恒定假设,以及它导出的那一个标量方程。(3) 比较融合时间的三种方式——3D 卷积、双流、时序注意力——并做那笔解释 3D 卷积为何昂贵的 FLOP 算术。(4) 把它落到生产中:流式延迟预算、因果模型与离线模型之别,以及课程索引承诺过的时序指标(片段准确率与视频准确率、时序定位的 mAP)。

1 · Frame sampling is a modeling choice

1 · 帧采样是一个建模决策

A one-minute clip at 30 frames per second (fps) and 224×224×3 is 60 · 30 · 224 · 224 · 3 ≈ 2.7 × 108 values — about 1.1 GB as float32 (4 bytes each; ~270 MB even stored as 8-bit bytes) before a single layer runs. You cannot feed it whole. So every video model begins with a sampling policy: how many frames, at what spacing, covering how much wall-clock time. That policy is not plumbing; it sets the ceiling on what the model can possibly learn, because information you do not sample, you cannot recover.

一段一分钟、每秒 30 帧(fps)、分辨率为 224×224×3 的片段是 60 · 30 · 224 · 224 · 3 ≈ 2.7 × 108 个数值——以 float32 计约 1.1 GB(每个 4 字节;即便以 8 位字节存储也有约 270 MB),而这还是在任何一层运行之前。你无法把它整个喂进去。所以每个视频模型都从一个采样策略开始:取多少帧、以什么间隔、覆盖多少真实时长。这个策略不是水管工程;它设定了模型可能学到的上限,因为你没有采样的信息,就无法复原。

Three knobs, with concrete consequences:

三个旋钮,各有具体后果:

The frequency view from lesson 02 applies directly: sampling in time is subject to the same Nyquist limit as sampling in space. To resolve an event that repeats at f Hz you must sample faster than 2f; below that, fast motion aliases into a slower phantom (the wagon-wheel effect — spokes appearing to spin backward). Choosing the frame rate is choosing your temporal anti-aliasing budget.

第 02 课的频率视角在这里直接适用:时间上的采样受制于与空间采样相同的奈奎斯特限。要分辨一个以 f Hz 重复的事件,你的采样必须快于 2f;低于这个速度,快速运动就会混叠成一个更慢的幻影(车轮效应——辐条看起来在倒转)。选择帧率,就是在选择你的时序抗混叠预算。

source 30 fps |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 30 frames / sec ↓ stride 8 (Δt ≈ 0.27 s) sampled |■.......■.......■.......■....| ~4 frames / sec ↑ a 0.1 s clap (3 source frames) can fall entirely in a gap — sampled too coarsely to ever be learned
Trap — the split leak comes back, worse陷阱——划分泄漏卷土重来,而且更糟
Adjacent frames are near-duplicates: frame t and t+1 differ by milliseconds of motion. Split a dataset at the frame level and almost every validation frame has a near-twin in training — the model memorizes, validation accuracy looks superb, production collapses. Split by source video, scene, or uploader, exactly the entity/time-level discipline lesson 07 demanded for images, now mandatory because the duplication is structural. 相邻帧是近乎重复的:第 t 帧与第 t+1 帧只相差几毫秒的运动。在级别划分数据集,几乎每一个验证帧在训练集里都有一个近乎孪生的兄弟——模型死记硬背,验证准确率看起来极好,生产环境却崩溃。要按源视频、场景或上传者划分,这正是第 07 课对图像所要求的那种实体/时间级别的纪律,如今更是必须的,因为这种重复是结构性的。

2 · What optical flow actually is

2 · 光流究竟是什么

"Motion signal" is vague. Optical flow makes it a number: for each pixel, the 2D displacement vector (u, v), measured in pixels per frame-step, that says where that bit of brightness moved between frame t and frame t+1 (so the "step" is one frame, Δt = 1 — the unit the Taylor expansion below quietly assumes). The whole construction rests on one assumption, the brightness-constancy assumption: a surface point keeps the same intensity as it moves a small amount over a small time. Writing the image intensity as I(x, y, t):

"运动信号"是含糊的。光流把它变成一个数:对每个像素,给出一个二维位移向量 (u, v),以像素每帧步长为单位,说明那一小块亮度在第 t 帧与第 t+1 帧之间移动到了哪里(所以这里的"步长"是一帧,Δt = 1——正是下面泰勒展开悄悄假定的那个单位)。整个构造建立在一个假设之上,即亮度恒定假设:一个表面点在小的时间内移动一小段距离时,保持相同的强度。把图像强度写作 I(x, y, t)

I(x, y, t) = I(x + u, y + v, t + 1) .

"A pixel's brightness doesn't change as it slides to its new location." Now expand the right side with a first-order Taylor approximation (valid when the motion is small — the assumption's fine print):

"一个像素的亮度在它滑向新位置时不会改变。"现在用一阶泰勒近似展开右边(在运动很小时成立——这就是那条假设的附加细则):

I(x + u, y + v, t+1) ≈ I(x, y, t) + Ix u + Iy v + It ,

where Ix, Iy are the spatial gradients (how brightness changes left-right and up-down — the Sobel responses from lesson 02) and It is the temporal gradient (frame difference at that pixel). This is just the multivariate f(a+Δ) ≈ f(a) + ∇f·Δ in three variables, with steps (u, v, 1) — so the It term is the time-derivative times the one-frame step. Substitute into brightness-constancy (set the two sides equal): the shared I(x,y,t) cancels, leaving the optical-flow constraint equation:

其中 Ix, Iy 是空间梯度(亮度在左右和上下方向如何变化——第 02 课的 Sobel 响应),而 It 是时间梯度(该像素处的帧差)。这不过是三变量下的多元式 f(a+Δ) ≈ f(a) + ∇f·Δ,步长为 (u, v, 1)——所以 It 这一项就是时间导数乘以一帧的步长。代入亮度恒定式(令两边相等):公共的 I(x,y,t) 相消,留下光流约束方程

Ix u + Iy v + It = 0   ⟺   ∇I · (u, v) + It = 0 .

Worked numerically. Suppose at one pixel the horizontal gradient is Ix = 10 intensity units/pixel, the vertical gradient Iy = 0 (a vertical edge — no vertical structure), and between frames the pixel got darker: It = −20 units. The constraint becomes 10u + 0·v − 20 = 0 ⟹ u = 2 pixels. We recovered the horizontal motion: the edge slid 2 pixels right. But v is completely undetermined — the equation says nothing about vertical motion along a vertical edge. This is the aperture problem: one equation, two unknowns per pixel. You only ever recover the motion component perpendicular to the local edge — called the normal flow. Classical solvers break the tie with extra assumptions — Lucas–Kanade assumes neighboring pixels share one (u,v) and solves a small least-squares system; Horn–Schunck adds a global smoothness penalty. Modern systems learn it: RAFT regresses flow with iterative refinement and beats the classical methods on benchmarks.

数值演算。假设在某个像素处,水平梯度为 Ix = 10 强度单位/像素,竖直梯度 Iy = 0(一条竖直边缘——没有竖直方向的结构),而两帧之间该像素变暗了:It = −20 单位。约束变成 10u + 0·v − 20 = 0 ⟹ u = 2 像素。我们复原了水平运动:边缘向右滑了 2 像素。但 v 完全无法确定——方程对沿竖直边缘的竖直运动只字未提。这就是孔径问题:每像素一个方程、两个未知数。你能复原的永远只是垂直于局部边缘的那个运动分量——称为法向光流。经典求解器靠额外假设来打破僵局——Lucas–Kanade 假设相邻像素共享同一个 (u,v),求解一个小的最小二乘系统;Horn–Schunck 则加上一个全局平滑惩罚。现代系统则把它学出来:RAFT 用迭代细化来回归光流,并在基准测试上胜过经典方法。

So flow is an explicit motion representation you can hand a model. The two-stream design (next section) does exactly that. The alternative is to let the model discover motion implicitly from raw frames — cheaper at inference (no flow to compute), but it must learn the equivalent of It internally and needs enough temporal data to do so.

所以光流是一种你可以直接交给模型的显式运动表示。双流设计(下一节)做的正是这件事。另一种选择是让模型从原始帧中隐式地发现运动——推理时更便宜(不必计算光流),但它必须在内部学到等价于 It 的东西,并且需要足够的时序数据才能做到。

2.5 · Interactive · the aperture problem

2.5 · 交互 · 孔径问题

The "one equation, two unknowns" claim is the whole reason flow is hard, and it is easiest to see. Watch a diagonal edge drift behind a small circular window: through that hole, you cannot tell whether the edge is moving sideways, up, or diagonally — every true-motion vector whose tip lands on a single dashed line produces the identical view. The constraint Ixu + Iyv + It = 0 is exactly that line. Only the component perpendicular to the edge (the normal flow, the blue arrow) is observable; the rest is undetermined. Add a corner — a second edge with a different orientation — and the two constraint lines intersect at one point: the ambiguity collapses to a unique vector, which is precisely what Lucas–Kanade does with a neighborhood.

"一个方程、两个未知数"这个论断正是光流之所以困难的全部原因,而它最容易被出来。看一条对角边缘在一个小圆窗后面漂移:透过那个孔,你分不清边缘是在横向、纵向还是斜向移动——凡是尖端落在同一条虚线上的真实运动向量,产生的视图都完全相同。约束 Ixu + Iyv + It = 0 恰好就是那条线。只有垂直于边缘的分量(法向光流,那支蓝色箭头)是可观测的;其余部分无法确定。加上一个角点——一条方向不同的第二条边缘——两条约束线便交于一点:歧义坍缩成唯一的向量,这正是 Lucas–Kanade 用一个邻域所做的事。

The aperture problem — one constraint line, not one vector
孔径问题——一条约束线,而非一个向量
Left: a moving edge (or corner) seen through a circular aperture. Right: velocity space (u,v) — the dashed line is every true motion consistent with what you observe through the hole; the blue arrow is the normal flow (the only recoverable component). Drag the true motion slider and watch the blue arrow refuse to change. Then switch to corner: two lines, one intersection, ambiguity resolved.
左图:透过一个圆形孔径看到的一条运动边缘(或角点)。右图:速度空间 (u,v)——虚线是与你透过孔看到的一切相符的所有真实运动;蓝色箭头是法向光流(唯一可复原的分量)。拖动真实运动滑块,看着蓝色箭头拒绝改变。然后切换到角点:两条线、一个交点,歧义被解决。
I_x , I_y
I_x , I_y
10, 0
I_t
I_t
−20
normal flow |v⊥|
法向光流 |v⊥|
2.0
solvable?
可解?
no — 1 eq
Show the core JS查看核心代码
// One edge gives one row of the constraint: I_x·u + I_y·v + I_t = 0.
// The spatial gradient ∇I points across the edge (normal n = ∇I/|∇I|).
// Brightness-constancy: I_t = -∇I · vTrue  (only the along-normal part of the true motion shows up).
function observe(theta, vTrue){
  const nx = Math.cos(theta), ny = Math.sin(theta);   // unit edge-normal
  const Ix = G*nx, Iy = G*ny;                          // gradient magnitude G along the normal
  const It = -(Ix*vTrue.u + Iy*vTrue.v);               // temporal gradient we'd measure
  const vn = -It / G;                                  // normal-flow magnitude (signed)
  return { Ix, Iy, It, normalFlow:{ u: vn*nx, v: vn*ny } };
}
// Single edge → the solution set is the LINE  I_x·u + I_y·v + I_t = 0  (under-determined).
// A corner adds a 2nd edge (theta2) → 2 lines intersect → unique (u,v) = the true motion.

The KPIs reproduce the worked example exactly: set θ so the edge is vertical (gradient purely horizontal, Iy=0) and a rightward true motion of 2 px gives Ix=10, Iy=0, It=−20 and normal flow 2 — yet "solvable?" stays no until you add the corner. That gap between a confident It reading and an unsolvable (u,v) is the aperture problem in one screen.

这些 KPI 精确地重现了那个演算例子:把 θ 设成让边缘竖直(梯度纯水平,Iy=0),一个向右 2 px 的真实运动给出 Ix=10, Iy=0, It=−20 以及法向光流 2——然而"可解?"一直是,直到你加上角点。一个笃定的 It 读数与一个无法求解的 (u,v) 之间的这道鸿沟,就是一屏之内的孔径问题。

3 · Three ways to fuse time — and why 3D conv is expensive

3 · 融合时间的三种方式——以及 3D 卷积为何昂贵

An image backbone (lesson 06) maps one frame to features. To use time we must combine information across frames. There are three dominant strategies.

一个图像骨干网络(第 06 课)把一帧映射为特征。要利用时间,我们必须帧地组合信息。有三种主流策略。

A · per-frame + pool f₁ f₂ f₃ pool cheap; loses ordering & fine motion B · 3D conv (space × time) k×k×t local motion; FLOPs × kernel-depth t C · two-stream / attention RGB flow fuse motion explicit (flow) or all-pairs (attn, O(n²))

3D convolution extends the 2D kernel of lesson 06 with a temporal depth: instead of a k×k window over one frame, a k×k×t window slides over a stack of t frames, learning spatio-temporal patterns (a flick, a bounce) directly. It is the most natural extension — and the most expensive. Here is the arithmetic, because the FLOP argument is the whole point.

3D 卷积把第 06 课的 2D 卷积核扩展出一个时间深度:不再是一个 k×k 的窗口滑过一帧,而是一个 k×k×t 的窗口滑过 t 帧的堆叠,直接学习时空模式(一次抖动、一次弹跳)。它是最自然的扩展——也是最昂贵的。下面是这笔算术,因为 FLOP 论证正是全部要点。

A 2D conv layer with Cin input channels, Cout output channels, kernel k×k, over a feature map of H×W spatial positions costs roughly

一个具有 Cin 个输入通道、Cout 个输出通道、卷积核 k×k、作用在 H×W 个空间位置的特征图上的 2D 卷积层,其开销大约是

FLOPs2D ≈ H · W · Cin · Cout · k · k .

The 3D version adds a temporal kernel dimension kt and processes D temporal positions (frames in the stack):

3D 版本加上一个时间卷积核维度 kt并且要处理 D 个时间位置(堆叠中的帧):

FLOPs3D ≈ D · H · W · Cin · Cout · k · k · kt .

Plug in numbers. Take H=W=56, Cin=Cout=256, k=3. The 2D layer: 56·56·256·256·9 ≈ 1.85 × 109 FLOPs per frame. Now a 3D layer over a D=16-frame clip with kt=3: 16·56·56·256·256·9·3 ≈ 8.9 × 1010 FLOPs — roughly D · kt = 48× the per-frame 2D cost. The temporal kernel multiplies cost by kt, and you pay it at every one of D frames. That blow-up is exactly why the field invented cheaper factorizations: (2+1)D convolutions split the k×k×kt kernel into a spatial k×k×1 followed by a temporal 1×1×kt (the separability trick from lesson 02, applied to time — fewer parameters and a non-linearity between them), and SlowFast spends the expensive high-resolution path only on a low-frame-rate stream.

代入数字。H=W=56Cin=Cout=256k=3。2D 层:56·56·256·256·9 ≈ 1.85 × 109 FLOPs 每帧。现在换成一个作用于 D=16 帧片段、kt=3 的 3D 层:16·56·56·256·256·9·3 ≈ 8.9 × 1010 FLOPs——大约是每帧 2D 开销的 D · kt = 48×。时间卷积核把开销乘以 kt,而这笔账你要在 D 帧中每一帧都付一遍。正是这种爆炸式增长,促使这一领域发明了更便宜的分解:(2+1)D 卷积把 k×k×kt 的卷积核拆成一个空间的 k×k×1 再跟一个时间的 1×1×kt(第 02 课的可分离性技巧,应用到时间上——参数更少,中间还夹一个非线性),而 SlowFast 只在低帧率的那一路上花费昂贵的高分辨率通路。

Two-stream networks sidestep learning motion from scratch: one CNN branch sees RGB (appearance — what is there), a second sees precomputed optical flow (motion — how it moves), and their predictions fuse. This was the early winner on action recognition precisely because flow hands the network the It signal it would otherwise struggle to extract. The cost is the flow computation itself — a second, often non-trivial, pipeline and failure surface.

双流网络绕开了从零学习运动:一条 CNN 分支看 RGB(外观——有什么),第二条看预先计算好的光流(运动——如何移动),二者的预测再融合。它之所以是动作识别的早期赢家,恰恰是因为光流把网络本来难以提取的 It 信号直接递到了手上。代价是光流计算本身——第二条往往并不简单的流水线,以及一处失败面。

Temporal attention tokenizes frames or patches and lets the transformer of lesson 13 attend across time. A video tokenizes into n spatio-temporal tokens, and self-attention is O(n²) — for video, n is huge (patches × frames), so the quadratic cost bites hard. Video transformers (TimeSformer, ViViT) make it tractable by factorizing attention: attend within a frame (spatial) and across the same patch over time (temporal) separately, turning O((P·F)²) into O(P² + F²) — the same divide-and-conquer instinct as (2+1)D conv and windowed attention.

时序注意力把帧或图块(patch)切成 token,让第 13 课的 Transformer 跨时间做注意力。一段视频被切成 n 个时空 token,而自注意力是 O(n²)——对视频而言,n 极大(图块 × 帧),所以二次开销咬得很凶。视频 Transformer(TimeSformer、ViViT)通过分解注意力把它变得可处理:分别在一帧之内(空间)与同一图块跨时间(时序)做注意力,把 O((P·F)²) 变成 O(P² + F²)——与 (2+1)D 卷积和窗口注意力如出一辙的分而治之直觉。

Family家族How it fuses time如何融合时间Cost driver开销主因Best when最适合于
Per-frame + pool逐帧 + 池化Image backbone per frame, average logits每帧一个图像骨干,对 logit 求平均cheapest; linear in frames最便宜;帧数线性action ≈ appearance (a scene, an object)动作 ≈ 外观(一个场景、一个物体)
3D CNN / (2+1)D3D CNN / (2+1)Dconv over space and time在空间时间上做卷积× D·kt over 2D相对 2Dfine local motion matters精细的局部运动很关键
Two-stream双流RGB branch + explicit optical-flow branchRGB 分支 + 显式光流分支flow precompute pipeline光流预计算流水线motion-defined actions, smaller data由运动定义的动作、数据较少
Temporal transformer时序 Transformerattention over frame/patch tokens在帧/图块 token 上做注意力O(n²), memory-heavy,显存开销大long-range temporal context, large data长程时序上下文、数据量大
Track-then-classify先跟踪后分类detect/track (lesson 11), classify trajectory检测/跟踪(第 11 课),再对轨迹分类tracker quality跟踪器质量object-centric events, few actors以物体为中心的事件、行动者少

4 · Streaming, latency budgets, and temporal metrics

4 · 流式处理、延迟预算与时序指标

The headline task is action recognition: assign a clip a label from a fixed set ("clapping", "pouring"). Its cousins are temporal action localization (find the start/end of each action in a long untrimmed video) and spatio-temporal detection (box + action per actor per frame). Each needs a metric that respects time.

头号任务是动作识别:为一个片段从固定集合中赋予一个标签("拍手""倒水")。它的近亲是时序动作定位(在一段未剪辑的长视频里找出每个动作的起止)和时空检测(每帧每个行动者的边界框 + 动作)。每一种都需要一个尊重时间的指标。

The streaming latency budget. An offline model may use future frames — it can look at frame t+10 to label frame t. A real-time model cannot; it is causal, seeing only the past. Concretely, suppose a product has a 100 ms end-to-end budget per frame at 30 fps (a frame arrives every 1000/30 ≈ 33 ms). If inference takes 70 ms, you have 30 ms for decode + preprocess + post-process, and you cannot buffer 10 future frames for smoothing without adding 10·33 = 330 ms of delay — blowing the budget more than 3×. So streaming forces choices the offline benchmark never penalizes: smaller clips, causal (no-lookahead) temporal modeling, frame-skipping under load, and lightweight temporal smoothing (an exponential moving average over recent logits) that trades a little lag for stability. The trap: heavy smoothing hides exactly the quick events you may most need to catch.

流式延迟预算。离线模型可以使用未来的帧——它能看第 t+10 帧来给第 t 帧打标签。实时模型不行;它是因果的,只能看到过去。具体地说,假设一个产品在 30 fps 下有 100 ms 的端到端逐帧预算(每 1000/30 ≈ 33 ms 到来一帧)。若推理耗时 70 ms,你只剩 30 ms 用于解码 + 预处理 + 后处理,而你无法缓冲 10 个未来帧来做平滑,否则会加进 10·33 = 330 ms 的延迟——把预算超支 3 倍以上。所以流式处理迫使你做出离线基准从不惩罚的取舍:更小的片段、因果(无前瞻)的时序建模、负载下跳帧,以及轻量的时序平滑(对近期 logit 做指数移动平均),用一点点滞后换取稳定。陷阱在于:过重的平滑恰恰会掩盖你可能最需要捕捉的那些快速事件。

Handoff to 17交接到第 17 课
Everything in lessons 01–16 has analyzed pixels — classified them, localized them, tracked them through time, aligned them to text. We have been a very sophisticated reader of images. The obvious next question: can a model run the arrow the other way and synthesize pixels — turn a label, a caption, or pure noise into an image or a video? That is a fundamentally different objective, and lesson 17 builds it from p(x) up. 第 01–16 课里的一切都在分析像素——给它们分类、定位、随时间跟踪、与文本对齐。我们一直是一名非常老练的图像读者。显而易见的下一个问题是:模型能不能把箭头反过来指,去合成像素——把一个标签、一句描述或纯噪声变成一张图像或一段视频?那是一个根本不同的目标,而第 17 课将从 p(x) 出发把它建立起来。

Where this points next

这将指向何处

We added time and found that the loader is part of the model: sampling rate sets the information ceiling, flow gives an explicit motion signal grounded in one brightness-constancy equation, and the choice of 3D conv / two-stream / attention is a FLOP-and-data trade. But all of this still consumes video. Lesson 17 (Generative vision) attacks the inverse problem — generation — and it is not classification run backward. Estimating p(x) over the space of all images (and the per-pixel multimodality that makes VAEs blur) demands new machinery: autoencoders, the adversarial game of GANs, and the denoising chain of diffusion that now powers text-to-image and text-to-video. The temporal lessons here resurface there: video generation is diffusion with the time axis we just learned to sample.

我们加上了时间,并发现数据加载器是模型的一部分:采样率设定了信息上限,光流给出一个扎根于一条亮度恒定方程的显式运动信号,而 3D 卷积 / 双流 / 注意力之间的选择是一笔 FLOP 与数据的权衡。但这一切仍然在消费视频。第 17 课(生成式视觉)攻打反问题——生成——而它不是把分类反过来跑。在所有图像构成的空间上估计 p(x)(以及让 VAE 变糊的逐像素多模态性)需要新的机器:自编码器、GAN 的对抗博弈,以及如今驱动文生图和文生视频的扩散去噪链。这里的时序课程会在那里重新浮现:视频生成就是带上我们刚学会采样的那条时间轴的扩散。

Takeaway要点
Video is images plus a time axis, and the first modeling decision is frame sampling — rate, stride, clip length, pattern — because unsampled events are unlearnable and frame-level splits leak catastrophically. Motion can be made explicit via optical flow, which rests on brightness-constancy I(x,y,t)=I(x+u,y+v,t+1) and yields the one-equation, two-unknown constraint Ixu + Iyv + It = 0 (hence the aperture problem). Time is fused by 3D conv (costs D·kt× a 2D layer — the reason for (2+1)D factorization), two-stream (RGB + flow), or temporal attention (O(n²), factorized in practice). Production splits the world into offline (uses the future) and streaming (causal, on a hard per-frame latency budget), and is judged by clip-vs-video accuracy and temporal-IoU mAP. 视频是图像加上一条时间轴,而第一个建模决策是帧采样——帧率、步幅、片段长度、模式——因为未采样的事件是无法学习的,而帧级别的划分会灾难性地泄漏。运动可以通过光流被显式化,它建立在亮度恒定 I(x,y,t)=I(x+u,y+v,t+1) 之上,并导出那个一方程、两未知数的约束 Ixu + Iyv + It = 0(因此有了孔径问题)。时间的融合可用 3D 卷积(开销是 2D 层的 D·kt×——这正是 (2+1)D 分解的缘由)、双流(RGB + 光流),或时序注意力O(n²),实践中做分解)。生产把世界一分为二:离线(使用未来)与流式(因果、受制于严苛的逐帧延迟预算),并以片段准确率对视频准确率、以及时序 IoU 的 mAP 来评判。

Interview prompts

面试题