AI Logic

Architectures

LGSS (Movie Scene Segmentation)

Updated:

Architecture of LGSS. The left side shows the overall flow: shots are represented by four elements and pass through BNet at the clip level, a Bi-LSTM and a threshold at the segment level, and optimal grouping over the whole movie, which outputs whether each shot boundary is a scene boundary. The right side shows the inside of BNet: the outputs of a branch that convolves the two shots on each side of the boundary and takes their dot product and a branch that convolves all four shots and applies max pooling are concatenated

Background and Overview

LGSS (Local-to-Global Scene Segmentation) is a method that first splits a movie into shots and then decides which of the boundaries between shots are "scene" boundaries, in three stages that widen from the vicinity of a shot (local) to the whole movie (global). Rao et al. of the Chinese University of Hong Kong and SenseTime presented it at CVPR in 2020, together with MovieScenes, a dataset of 150 movies annotated with scene boundaries.

First, consider the difference between a shot and a scene.

  • Shot: A continuous run of frames captured by one camera without interruption. Because the visuals are continuous, existing tools can split shots easily (evaluating shot boundary detection, TransNet V2).
  • Scene: A narratively coherent unit in which some event happens among certain people. It consists of many shots and may cut back and forth between two places, as in a phone-call scene.

Splitting into scenes requires linking shots that look different but are connected in the story. For example, a close-up of a woman inviting someone to dance does not reveal the situation on its own, but together with the surrounding shots it becomes clear that "she is asking a couple to dance in front of a band."

The paper approached this task with the following three ideas.

  1. Learn the boundaries: Instead of classifying scene contents, it learns, with supervision, the binary classification of "whether a shot boundary is a scene boundary."
  2. Use multiple cues: Each shot is represented by four elements: place, cast, action, and audio.
  3. Revisit from the whole movie: Local predictions are corrected by an optimal grouping over the whole movie.

As a result, average precision (AP) on MovieScenes rose from 28.1 for the previous best method to 47.1.

Theory: Deciding Scene Boundaries in Three Stages

Let a movie be a sequence of nn shots [s1,⋯ ,sn][s_1, \cdots, s_n], with oi=1o_i = 1 if the boundary between the ii-th and (i+1)(i+1)-th shots is a scene boundary and oi=0o_i = 0 otherwise. LGSS stacks models at three levels (clip, segment, and whole movie), B\mathcal{B}, T\mathcal{T}, and G\mathcal{G}, to output the n−1n - 1 values oio_i (left side of the figure at the top of the article).

G{T[B([s1,s2,⋯ ,sn])]}=[o1,o2,⋯ ,on−1]\mathcal{G}\{\mathcal{T}[\mathcal{B}([s_1, s_2, \cdots, s_n])]\} = [o_1, o_2, \cdots, o_{n-1}]

0. Represent shots with four elements

Each shot sis_i is represented by four features produced by pretrained models.

ElementHow it is produced
PlaceFeed a representative frame of the shot into a ResNet-50 trained on Places, a dataset of place images
CastDetect people with a Faster R-CNN trained on movie-character data, and embed them with a ResNet-50 trained on person re-identification data
ActionTSN trained on the action dataset AVA
AudioSeparate speech and background sound with a separation model (NaverNet), convert each into features by short-time Fourier transform (16 kHz, window length 512), and concatenate them

1. Clip: representing shot boundaries (BNet)

Looking at the 2wb2w_b shots around boundary ii, it builds a boundary representation bib_i (right side of the figure at the top of the article). Based on the idea that a boundary representation needs both the difference and the relation between the shots before and after it, BNet has two branches.

  • Bd\mathcal{B}_d (difference): Embeds the wbw_b shots before the boundary and the wbw_b shots after it, each with a temporal convolution, and takes their dot product.
  • Br\mathcal{B}_r (relation): Applies a temporal convolution to all 2wb2w_b shots, followed by max pooling.
bi=[Bd([si−(wb−1),⋯ ,si],[si+1,⋯ ,si+wb])Br([si−(wb−1),⋯ ,si+wb])]b_i = \begin{bmatrix} \mathcal{B}_d([s_{i-(w_b-1)}, \cdots, s_i], [s_{i+1}, \cdots, s_{i+w_b}]) \\ \mathcal{B}_r([s_{i-(w_b-1)}, \cdots, s_{i+w_b}]) \end{bmatrix}

2. Segment: coarse prediction

From the sequence of boundary representations [b1,⋯ ,bn−1][b_1, \cdots, b_{n-1}], it outputs the probability pip_i that each boundary is a scene boundary. The number of shots nn in a movie usually exceeds 1,000, too long for a sequence model to handle at once. So a sequence model T\mathcal{T} such as a bidirectional RNN (Bi-LSTM) looks at wtw_t boundaries at a time (wt≪nw_t \ll n), sliding with stride wt/2w_t / 2. Thresholding the probabilities at τ\tau into 0 or 1 gives the coarse prediction oˉi\bar{o}_i.

[p1,⋯ ,pn−1]=T([b1,⋯ ,bn−1]),oˉi={1(pi>τ)0(otherwise)[p_1, \cdots, p_{n-1}] = \mathcal{T}([b_1, \cdots, b_{n-1}]), \qquad \bar{o}_i = \begin{cases} 1 & (p_i > \tau) \\ 0 & (\text{otherwise}) \end{cases}

3. Whole movie: searching for the optimal grouping

The coarse prediction only sees a range of wtw_t boundaries, so it is corrected using the flow of the whole movie.

  1. Each run of consecutive shots delimited by the coarse prediction is called a super shot CkC_k. In the paper's experiments, it starts from 600 super shots, splitting at boundaries in order of decreasing probability.
  2. The super shots are grouped into jj scenes Φ={ϕ1,…,ϕj}\Phi = \{\phi_1, \ldots, \phi_j\}. Since the number of scenes jj is unknown, every jj in a fixed range (50 to 400 in the experiments) is tried, and the jj and grouping that maximize the objective are selected.
  3. The objective is the sum of the scores g(ϕk)g(\phi_k) of the scenes ϕk\phi_k. gg is determined by the similarity between each super shot in a scene and the remaining super shots PkP_k of the same scene.
F⋆=max⁡j(max⁡Φ∑ϕk∈Φg(ϕk))s.t. j<∣C∣, ∣Φ∣=jF^\star = \max_j \left( \max_{\Phi} \sum_{\phi_k \in \Phi} g(\phi_k) \right) \quad \text{s.t.} \ j < |C|, \ |\Phi| = j g(ϕk)=∑Ck∈ϕk(Fs(Ck,Pk)+Ft(Ck,Pk))g(\phi_k) = \sum_{C_k \in \phi_k} \left( F_s(C_k, P_k) + F_t(C_k, P_k) \right) Fs(Ck,Pk)=1∣Pk∣∑C^k∈Pkcos⁡(Ck,C^k),Ft(Ck,Pk)=σ(max⁡C^k∈Pkcos⁡(Ck,C^k))F_s(C_k, P_k) = \frac{1}{|P_k|} \sum_{\hat{C}_k \in P_k} \cos(C_k, \hat{C}_k), \qquad F_t(C_k, P_k) = \sigma\left( \max_{\hat{C}_k \in P_k} \cos(C_k, \hat{C}_k) \right)

FsF_s is the average similarity within a scene and represents global relations. FtF_t indicates whether the scene contains even one very similar super shot, and is meant to capture "threads" such as a conversation in which shots with the same framing alternate.

  1. This optimization can be solved with dynamic programming. Take the best value for grouping the first kk super shots into j−1j - 1 scenes, add the score of making the rest one scene, and maximize over kk.
F⋆(n=j)=max⁡k{F⋆(n=j−1∣C1:k)+g(ϕj={Ck+1,…,C∣C∣})}F^\star(n = j) = \max_k \left\{ F^\star(n = j - 1 \mid C_{1:k}) + g(\phi_j = \{C_{k+1}, \ldots, C_{|C|}\}) \right\}
  1. The resulting scenes are treated as new super shots and grouped again, repeatedly (converging within 5 iterations in the experiments).

Training setup (Section 5.1 of the paper)

  • Non-scene boundaries outnumber scene boundaries by about 9 to 1, so the cross-entropy is weighted 1 : 9 to emphasize scene boundaries.
  • Adam for 30 epochs, with a learning rate starting at 0.01 and reduced to 1/10 at epoch 15 (step decay).
  • The best window lengths were 4 shots for BNet (wb=2w_b = 2) and 10 boundaries for the sequence model.

Why Split from Local to Global

LGSS makes its decision while widening its view, from a stage that looks at nearby shots to one that looks at the whole movie. Each stage has its role.

  • Clip (BNet): Represents not only "whether" the shots around a boundary differ but also "how they are related." It produces the material needed to judge that a scene continues when the same person keeps talking, even if the visuals change.
  • Segment (sequence model): Looks at about 10 boundaries in a row and outputs probabilities from the relations among them. The paper notes that about 14 shots, combined with BNet's 4, roughly matches the length of one scene.
  • Whole movie (optimal grouping): Local predictions tend to produce spurious boundaries where the visuals change abruptly, such as a switch from a long shot to a close-up or an extreme close-up. Global optimization groups super shots that are similar even if far apart into the same scene, removing these spurious boundaries.

As an everyday analogy, it is like dividing a novel into chapters. First, read and compare the text on either side of each paragraph break (clip), check the flow of the story a few pages at a time (segment), and finally re-divide while looking at the balance of the number and length of chapters overall (whole movie).

The four elements complement one another

The paper examined the magnitude of similarity for each element and showed with examples which element served as the cue for determining a scene.

  • If consecutive shots show the same person, cast is the cue.
  • Even for shots of people filmed small from afar or with no faces visible, similar audio reveals that they belong together.
  • In a phone-call scene, the action can be similar even when the places differ.
  • In some cases, only the place is shared, and it forms one scene even though the people and actions differ.

Because which element helps varies by scene, combining all four improves accuracy.

Experimental Results

The paper evaluates on MovieScenes (150 movies, 270,450 shots, 21,428 scenes, 297 hours in total), split by movie into training, validation, and test sets at 10 : 2 : 3. The three evaluation metrics are as follows.

  • AP: Average precision for scene boundaries (oi=1o_i = 1) computed per movie and then averaged (the same idea as mAP)
  • Miou: The sum of IoUs for each detected boundary, weighted by the distance to the nearest ground-truth boundary
  • Recall@3s: The fraction of ground-truth boundaries that lie within 3 seconds of a predicted boundary

Overall results (Table 3 of the paper; prior methods were rebuilt with deep place features for a fair comparison)

MethodAPMiouRecallRecall@3s
Random guess8.226.849.854.2
GraphCut14.129.753.757.2
SCSA14.730.554.958.0
DP15.532.055.658.4
Grouping17.633.156.658.7
StoryGraph25.135.758.459.7
Siamese28.136.060.161.2
LGSS (place only, temporal convolution)19.534.057.158.9
+ four elements24.334.857.659.4
+ BNet42.244.767.578.1
+ sequence model44.946.571.477.5
+ global optimal grouping (LGSS)47.148.873.679.8
Human upper bound81.091.094.199.5

The largest AP gain came from BNet (24.3 → 42.2), and the paper states that directly representing shot boundaries helps scene segmentation. LGSS beat the previous best, Siamese, by 19.0 AP. On the other hand, a large gap remains to the human upper bound (81.0).

Combinations of elements (Table 4 of the paper; AP with BNet, the sequence model, and optimal grouping)

Elements usedAP
Place only39.0
Place + audio43.4
Place + action45.5
Place + cast43.0
All four47.1

Adding any of audio, action, or cast to place improved results, and all four together were best. The four elements also helped prior methods: Siamese rose from 28.1 to 34.1 and StoryGraph from 25.1 to 33.2.

Window lengths (Table 5 of the paper; rows are BNet's number of shots, columns are the sequence model's length; AP)

BNet \ sequence1251020
243.444.245.446.346.5
444.945.245.747.146.9
644.745.045.846.746.6

Transfer to other datasets (Table 7 of the paper, AP)

MethodOVSDBBC
Siamese65.662.3
LGSS76.279.5
Siamese (pretrained on MovieScenes)76.871.4
LGSS (pretrained on MovieScenes)85.790.2

On OVSD, a collection of short films, and on BBC documentaries (BBC Planet Earth), pretraining on MovieScenes raised AP substantially. The paper attributes this to MovieScenes containing far more kinds of scenes.

Practical Considerations

Keep the following points in mind when using LGSS.

  • It presupposes shot segmentation: LGSS takes a movie already split into shots and selects which shot boundaries are scene boundaries. Scene boundaries are a subset of shot boundaries, so errors in shot segmentation carry through unchanged.
  • Many preprocessing models: Producing the four elements requires pretrained models for place, person detection and identification, action, and audio separation. When applying it to videos from a new domain, check that each model works on those videos.
  • Tune the global optimization knobs to the data: The initial number of super shots (600) and the range of scene counts (50 to 400) were chosen from MovieScenes statistics. In the paper, AP varied from 46.0 to 47.1 for initial counts between 400 and 1,000. For videos of different lengths (such as a single TV episode), revisit the range.
  • The released code's settings may differ from the paper: The authors' released code (SceneSeg) has a BNet and Bi-LSTM for each of the four elements and sums their outputs with weights (place 0.5, cast 0.2, action 0.2, audio 0.1). Its data folder names are for 318 movies, so its setup may differ from the paper's 150-movie MovieScenes.

Scene boundaries make up only about 10% of shot boundaries. In the paper's test data, the ratio of scene boundaries to other boundaries is about 1 : 9, and even a random guess achieves a Recall@3s of 54.2. It is important to weight the loss to emphasize the minority class and, in evaluation, to also look at metrics robust to imbalance such as AP.

Comparison with Other Methods

Comparing methods for splitting movie and TV videos into scenes from the same angles gives the following.

MethodLearningCues usedScopeLimitations
Methods grouping shots by color and similar features (GraphCut, SCSA, etc.)UnsupervisedLow-level visual featuresNearby shotsKnobs must be set by hand for each video
DPUnsupervisedA predefined objective functionWhole movie (dynamic programming)Hand-crafted objective
StoryGraph, SiameseSupervisedMainly visual featuresWide rangeHard to capture semantic coherence
LGSSSupervisedPlace, cast, action, audioClip → segment → whole movieMany preprocessing models

The difference between shot boundary detection and scene segmentation is compared from the same angles as well.

TaskUnitCuesRepresentative method
Shot boundary detectionFrame boundariesVisual change between adjacent framesTransNet V2
Scene segmentationShot boundariesNarrative connections (cast, place, action, audio)LGSS
Action segmentationPer-frame action labelsMotion and appearance, action orderMS-TCN

Rough guidelines for choosing are as follows.

  • To split movies or dramas into narrative units: First split into shots, then use a method like LGSS that classifies shot boundaries.
  • To find transitions such as cuts and dissolves: These are shot boundaries rather than scenes, so use shot boundary detection such as TransNet V2.
  • To split into predefined types of actions, as with cooking steps: Since there are action classes, use an action segmentation method such as MS-TCN.

PyTorch example

Show code
python
import torch
import torch.nn as nn
import torch.nn.functional as F

"""
A small implementation example of LGSS (Rao et al. 2020, Sections 4.2-4.4), using features of only one element (e.g., place)
1. BNet: builds the boundary representation b_i from the 2*wb shots around the boundary (Eq. 2)
2. Bi-LSTM: outputs scene-boundary probabilities p_i for wt boundaries at a time (Eq. 3)
3. Dynamic programming: groups super shots into j scenes (a simplified form of Eq. 6)
"""


class BNet(nn.Module):
  def __init__(self, feat_dim, wb=2, ch=512):
    super().__init__()
    self.wb = wb
    self.conv_half = nn.Conv1d(feat_dim, ch, kernel_size=wb)       # B_d: embed the wb shots before (after)
    self.conv_all = nn.Conv1d(feat_dim, ch, kernel_size=2 * wb)    # B_r: all 2wb shots

  def forward(self, clip):                     # clip: (N, 2*wb, D) shots around the boundary
    x = clip.transpose(1, 2)                   # (N, D, 2*wb)
    before = self.conv_half(x[:, :, :self.wb]).squeeze(-1)
    after = self.conv_half(x[:, :, self.wb:]).squeeze(-1)
    diff = (before * after).sum(dim=1, keepdim=True)   # measure the difference before/after with a dot product
    rel = self.conv_all(x).amax(dim=-1)                # convolution → max pooling
    return torch.cat([diff, rel], dim=1)               # boundary representation b_i


class LGSSLocal(nn.Module):
  def __init__(self, feat_dim, wb=2, ch=512, hidden=512):
    super().__init__()
    self.bnet = BNet(feat_dim, wb, ch)
    self.lstm = nn.LSTM(ch + 1, hidden, batch_first=True, bidirectional=True)
    self.head = nn.Linear(2 * hidden, 2)       # scene boundary or not

  def forward(self, clips):                    # clips: (N, wt, 2*wb, D) clips for wt boundaries
    n, wt = clips.shape[:2]
    b = self.bnet(clips.flatten(0, 1)).view(n, wt, -1)
    out, _ = self.lstm(b)
    return self.head(out)                      # (N, wt, 2)


model = LGSSLocal(feat_dim=2048)
clips = torch.randn(8, 10, 4, 2048)            # 8 segments, 10 boundaries each, 4 shots per boundary
target = torch.randint(0, 2, (8, 10))          # 1 means a scene boundary
weight = torch.tensor([1.0, 9.0])              # weights non-boundary : boundary = 1 : 9 (Section 5.1)

model.train()
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
loss = F.cross_entropy(model(clips).flatten(0, 1), target.flatten(), weight=weight)
optimizer.zero_grad()
loss.backward()
optimizer.step()

model.eval()
with torch.no_grad():
  p = model(clips).softmax(-1)[..., 1]         # scene-boundary probabilities p_i


def scene_score(feats):
  """g(φ): cosine similarity between each super shot in the scene and the rest (mean + σ of max)"""
  if len(feats) == 1:
    return torch.tensor(0.0)
  sim = F.cosine_similarity(feats[:, None], feats[None], dim=-1)
  sim = sim.masked_fill(torch.eye(len(feats), dtype=torch.bool), float("nan"))
  mean = torch.nanmean(sim, dim=1)
  mx = torch.nan_to_num(sim, nan=-1.0).amax(dim=1)
  return (mean + torch.sigmoid(mx)).sum()


def optimal_grouping(super_feats, num_scenes):
  """Dynamic programming that splits a sequence of super shots into num_scenes consecutive groups"""
  m = len(super_feats)
  best = torch.full((num_scenes + 1, m + 1), float("-inf"))
  arg = torch.zeros((num_scenes + 1, m + 1), dtype=torch.long)
  best[0, 0] = 0.0
  for j in range(1, num_scenes + 1):
    for end in range(j, m + 1):
      for k in range(j - 1, end):              # the last scene is k..end-1
        v = best[j - 1, k] + scene_score(super_feats[k:end])
        if v > best[j, end]:
          best[j, end], arg[j, end] = v, k
  cuts, end = [], m
  for j in range(num_scenes, 0, -1):
    end = arg[j, end].item()
    cuts.append(end)
  return sorted(cuts)[1:], best[num_scenes, m].item()   # scene start positions and objective value


super_feats = torch.randn(12, 2048)            # representations of 12 super shots from the coarse prediction
print(optimal_grouping(super_feats, num_scenes=4))

FAQ

Q. How does shot boundary detection differ from scene segmentation?
A.

A shot is a unit captured by one camera without interruption, and it can be split by finding where the appearance of adjacent frames changes sharply (TransNet V2 and others). A scene is a narratively coherent unit made of many shots. It is a harder task because shots that look different must be grouped into the same scene based on connections such as cast, place, action, and audio. LGSS decides which shot boundaries are scene boundaries.

Q. Which part of LGSS helps the most?
A.

In Table 3 of the paper, adding BNet, which directly represents shot boundaries, produced the largest AP gain, from 24.3 to 42.2. The sequence model (44.9) and the global optimal grouping (47.1) then add smaller gains. The four elements (place, cast, action, audio) also raised AP from 39.0 with place alone to 47.1.

Q. What does the global optimal grouping do?
A.

When grouping the units delimited by the local predictions (super shots) into a given number of scenes, it scores a scene higher the more similar its super shots are to one another, and uses dynamic programming to find the split that maximizes the total. Since the number of scenes is also unknown, it tries every number in a range. This removes spurious boundaries that arise where the visuals change abruptly, such as a switch from a long shot to a close-up.

References

  1. Rao, A., Xu, L., Xiong, Y., Xu, G., Huang, Q., Zhou, B., & Lin, D. (2020). A Local-to-Global Approach to Multi-modal Movie Scene Segmentation. CVPR 2020. arXiv:2004.02678.
  2. AnyiRao/SceneSeg (the authors' released code, lgss/src/models/lgss.py and lgss/config/all.py).
  3. Baraldi, L., Grana, C., & Cucchiara, R. (2015). A Deep Siamese Network for Scene Detection in Broadcast Videos. ACM Multimedia 2015. arXiv:1510.08893.