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.
Learn the boundaries: Instead of classifying scene contents, it learns, with supervision, the binary classification of "whether a shot boundary is a scene boundary."
Use multiple cues: Each shot is represented by four elements: place, cast, action, and audio.
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 n shots [s1,⋯,sn], with oi=1 if the boundary between the i-th and (i+1)-th shots is a scene boundary and oi=0 otherwise. LGSS stacks models at three levels (clip, segment, and whole movie), B, T, and G, to output the n−1 values oi (left side of the figure at the top of the article).
G{T[B([s1,s2,⋯,sn])]}=[o1,o2,⋯,on−1]
0. Represent shots with four elements
Each shot si is represented by four features produced by pretrained models.
Element
How it is produced
Place
Feed a representative frame of the shot into a ResNet-50 trained on Places, a dataset of place images
Cast
Detect people with a Faster R-CNN trained on movie-character data, and embed them with a ResNet-50 trained on person re-identification data
Separate 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 2wb shots around boundary i, it builds a boundary representation bi (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 (difference): Embeds the wb shots before the boundary and the wb shots after it, each with a temporal convolution, and takes their dot product.
Br (relation): Applies a temporal convolution to all 2wb shots, followed by max pooling.
From the sequence of boundary representations [b1,⋯,bn−1], it outputs the probability pi that each boundary is a scene boundary. The number of shots n in a movie usually exceeds 1,000, too long for a sequence model to handle at once. So a sequence model T such as a bidirectional RNN (Bi-LSTM) looks at wt boundaries at a time (wt≪n), sliding with stride wt/2. Thresholding the probabilities at τ into 0 or 1 gives the coarse prediction oˉi.
3. Whole movie: searching for the optimal grouping
The coarse prediction only sees a range of wt boundaries, so it is corrected using the flow of the whole movie.
Each run of consecutive shots delimited by the coarse prediction is called a super shotCk. In the paper's experiments, it starts from 600 super shots, splitting at boundaries in order of decreasing probability.
The super shots are grouped into j scenes Φ={ϕ1,…,ϕj}. Since the number of scenes j is unknown, every j in a fixed range (50 to 400 in the experiments) is tried, and the j and grouping that maximize the objective are selected.
The objective is the sum of the scores g(ϕk) of the scenes ϕk. g is determined by the similarity between each super shot in a scene and the remaining super shots Pk of the same scene.
Fs is the average similarity within a scene and represents global relations. Ft 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.
This optimization can be solved with dynamic programming. Take the best value for grouping the first k super shots into j−1 scenes, add the score of making the rest one scene, and maximize over k.
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=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=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)
Method
AP
Miou
Recall
Recall@3s
Random guess
8.2
26.8
49.8
54.2
GraphCut
14.1
29.7
53.7
57.2
SCSA
14.7
30.5
54.9
58.0
DP
15.5
32.0
55.6
58.4
Grouping
17.6
33.1
56.6
58.7
StoryGraph
25.1
35.7
58.4
59.7
Siamese
28.1
36.0
60.1
61.2
LGSS (place only, temporal convolution)
19.5
34.0
57.1
58.9
+ four elements
24.3
34.8
57.6
59.4
+ BNet
42.2
44.7
67.5
78.1
+ sequence model
44.9
46.5
71.4
77.5
+ global optimal grouping (LGSS)
47.1
48.8
73.6
79.8
Human upper bound
81.0
91.0
94.1
99.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 used
AP
Place only
39.0
Place + audio
43.4
Place + action
45.5
Place + cast
43.0
All four
47.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 \ sequence
1
2
5
10
20
2
43.4
44.2
45.4
46.3
46.5
4
44.9
45.2
45.7
47.1
46.9
6
44.7
45.0
45.8
46.7
46.6
Transfer to other datasets (Table 7 of the paper, AP)
Method
OVSD
BBC
Siamese
65.6
62.3
LGSS
76.2
79.5
Siamese (pretrained on MovieScenes)
76.8
71.4
LGSS (pretrained on MovieScenes)
85.7
90.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.
Method
Learning
Cues used
Scope
Limitations
Methods grouping shots by color and similar features (GraphCut, SCSA, etc.)
Unsupervised
Low-level visual features
Nearby shots
Knobs must be set by hand for each video
DP
Unsupervised
A predefined objective function
Whole movie (dynamic programming)
Hand-crafted objective
StoryGraph, Siamese
Supervised
Mainly visual features
Wide range
Hard to capture semantic coherence
LGSS
Supervised
Place, cast, action, audio
Clip → segment → whole movie
Many preprocessing models
The difference between shot boundary detection and scene segmentation is compared from the same angles as well.
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.