Video understanding, tracking, generation, and world models · Video segmentation · VID037 · Model
Space-Time Correspondence Networks (STCN)
Propagates object masks through video using correspondence between a query frame and remembered frames. Its memory-matching design improves how past visual evidence covers the current frame, supporting semi-supervised…
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Propagates object masks through video using correspondence between a query frame and remembered frames. Its memory-matching design improves how past visual evidence covers the current frame, supporting semi-supervised video object segmentation from an initial mask.
Question / objective
Maintain an explicitly identified object mask across frames under a defined annotation or prompting protocol. This is a learning or inference objective, not a test of a statistical null hypothesis.
Method type and supervision
model · Video segmentation. Annotated training plus an object initialization/prompt protocol at inference; not purely unsupervised.
Architecture / computational structure
Key/value memory encoding, distance-based correspondence and object-mask decoding.
Assumptions
Inputs must satisfy the temporal, modality and annotation protocol described below. The initial object annotation is supervision. Appearance changes and memory errors can propagate; a matching map is not a calibrated probability that a pixel belongs to an object.
Formula / computational definition
and illustrate memory retrieval: query/memory keys determine weights and memory values carry object information.
Parameters and notation
Learned/estimated quantities: Visual/key/value/prompt/decoder weights are learned as applicable; stored per-video memories and masks are runtime state. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Memory frame selection, key/value dimension, input resolution, number of objects and similarity normalization matter.
Fitting, fine-tuning, and adaptation
Adapt memory encoders and decoder on labeled mask sequences. Begin with the decoder on small datasets; memory-selection policy is a hyperparameter rather than gradient-updated memory content. Use a separate adaptation validation split, monitor the target metric and retention of previously useful behavior, and save the exact preprocessing and training configuration.
How to use and calibrate
Fix the input protocol and target before fitting; choose design settings on held-out source videos, then freeze the evaluation procedure. Evaluate region overlap and contour accuracy, memory use and long-sequence behavior, following benchmark initialization rules.
Example application
Propagate a first-frame object mask through a video.
Interpretation / pitfalls
Watch out
An optimized training objective or a favorable example does not establish generalization. Evaluate region overlap and contour accuracy, memory use and long-sequence behavior, following benchmark initialization rules. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.
Python and R code examples
Component: Retrieve object values from squared-distance memory keys. Dependencies: NumPy in Python; base R in R; run the shared setup above. Python component: executed successfully. R component: unexecuted. No complete model training or pretrained inference was executed.
Full implementation route — Python: Use the authors' STCN implementation and record memory insertion settings. R: Demonstrate distance-based memory retrieval in R; invoke Python segmentation and evaluate masks in R.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Retrieve object values from squared-distance memory keys.
Shared setup for this chapter
import numpy as np
def softmax(x):
z = np.asarray(x, dtype=float)
e = np.exp(z - z.max())
return e / e.sum()
query = np.array([.9,.1])
keys = np.array([[1.,0.],[0.,1.],[.8,.2]])
values = np.array([1.,0.,1.])
weights = softmax(-np.sum((keys-query)**2,axis=1))
print("memory weights",weights,"retrieved value",weights@values)
Component demo, not a trained model — Retrieve object values from squared-distance memory keys.
Shared setup for this chapter
softmax <- function(x) {
e <- exp(x - max(x))
e / sum(e)
}
query <- c(.9,.1); keys <- rbind(c(1,0),c(0,1),c(.8,.2))
values <- c(1,0,1)
distance <- rowSums(sweep(keys,2,query,"-")^2)
weights <- softmax(-distance)
print(weights); print(sum(weights*values))
Sources
- Source 1github.com
From the CodeSplash reference, entry VID037.