XMem tracks masks through long videos

XMem is a video object segmentation model that carries an object mask from one frame through the rest of a long video. In Supervisely it sits behind the Track button of the video labeling tool: segment the object once, and XMem segments it in the frames that follow.

XMem segmenting a motorcyclist through the frames of a jump
Labels
  • Bitmap masks in video
Apps
Track
Source
GitHub, Paper

Apps in the Supervisely Ecosystem

Every model in Supervisely comes as a Supervisely App: a module from the Ecosystem that plugs into the platform and runs on your own GPU, with no code to install. A Serve App puts the model behind the labeling tools, and where the model can be trained, a Train App fits it to your labeled project. All Apps work on the same projects, so you add a model, update it or swap it for another without changing anything else.

XMem and its three memories

XMem was introduced in "Long-Term Video Object Segmentation with an Atkinson-Shiffrin Memory Model" by Ho Kei Cheng and Alexander Schwing of the University of Illinois Urbana-Champaign (paper, code). It solves semi-supervised video object segmentation: you give the mask on one frame, and the model finds the same object in every other frame. In Supervisely the result is one video object with a mask on each tracked frame, so the object keeps its identity and class from the first frame to the last.

Most earlier methods kept one kind of memory, so on long videos either GPU memory grew without bound or detail was compressed away. XMem keeps three stores, after a model of human memory: a sensory memory updated every frame, a high-resolution working memory, and a compact long-term memory that features are promoted into. According to the authors, this lets it handle videos of more than 10,000 frames and objects that disappear behind something and come back.

Starting XMem

On most instances an administrator starts XMem once for everyone, and it is already available in the video labeling tool. If it is not, run it yourself:

  1. Find XMem Video Object Segmentation in the Ecosystem, or on the Neural Networks page under Videos, Segmentation & tracking.
  2. Run it on an agent with a GPU. On the Community Edition this is a GPU computer of your own connected to the platform.
  3. Open a video in the video labeling toolbox.

Segment once, then press Track

XMem needs a mask to start from. Draw it on the first frame where the object is clear, with the brush or with an interactive model such as SAM 2.1, then press Track. The mask follows the object over the frames you chose; scrub through, fix the frames where it slipped, and track again from the fix.

A few habits make tracks cleaner: start from a frame where the object is not cut by the image border, track in shorter spans through fast motion, and re-track from the last good frame instead of repairing many bad ones. The XMem tutorial shows the whole loop with Segment Anything, and the guide to object tracking covers tracking more broadly.

XMem or another tracker?

You labelTrack with
Masks in long footage with occlusionsXMem
Masks you want to start from clicks and track in one toolSAM 2.1 or SAM 3
Points, polylines, polygons or keypoint skeletonsCoTracker

XMem is served only; there is no training app for it. Videos import into a project as they are, and their annotations are kept in Supervisely JSON, which the formats hub describes for video as well.

Frequently asked questions.

What is XMem?

XMem is a semi-supervised video object segmentation model: you give the mask of an object on one frame, and it finds the same object in the other frames. Its sensory, working and long-term memories let it handle videos of more than 10,000 frames, according to its authors.

Can I train XMem on my own data in Supervisely?

No. XMem is served only; there is no training app for it. Run XMem Video Object Segmentation on an agent with a GPU and use it from the Track button of the video labeling tool.

Should I track masks with XMem or SAM 2.1?

XMem suits masks in long footage with occlusions. SAM 2.1 or SAM 3 suit masks you want to start from clicks and track in one tool, and CoTracker tracks points, polylines, polygons and keypoint skeletons.

Train and serve models on your own data.

Label a project in a free account, train a model on it from the browser and deploy it on your own GPU. Or book a demo to run Supervisely on your servers.