Buffered STCN for Online and Offline Segmentation of Long Videos
This is a fork of the STCN video object segmentation method. It is optimized for online prediction for long videos. That is, feeding a video stream to the network frame-by-frame and obtaining the predictions for each frame immediately. By contrast, the original repository only allows batch processing where the whole video needs to be loaded first and the result is given for the whole sequence at once.
To avoid running out of memory in case of long videos, I extended STCN with a buffer mechanism. Once the memory bank buffer reaches a specified number of frames, each new insertion replaces a random existing element in the buffer. This randomization results in an exponentially distributed sample, favoring recent time steps.
For offline use, permuting the frames randomly and performing a burn-in pass (or several) achieves better segmentation quality. This way the memory will contain samples from the whole video sequence, which helps if the subject undergoes some appearance changes, such as lighting change, clothing change, distance or zoom, turning around, etc. The final pass can be done in order, keeping the previous few frames also in the memory in addition to the burn-in result.
For initializing the segmentation, the intial timestamp can be provided; otherwise the middle frame is used. Mask-RCNN is run on this frame and then either the user can click the subjects to track using a GUI, or the highest-scoring detections are used.
The code has been refactored in many other aspects as well, including removing einops usage in order to support TorchScript compilation.
References
Original STCN:
Ho Kei Cheng, Yu-Wing Tai, Chi-Keung Tang. Rethinking Space-Time Networks with Improved Memory Coverage for Efficient Video Object Segmentation. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
https://github.com/hkchengrex/STCN
@inproceedings{cheng2021stcn,
title={Rethinking Space-Time Networks with Improved Memory Coverage for Efficient Video Object Segmentation},
author={Cheng, Ho Kei and Tai, Yu-Wing and Tang, Chi-Keung},
booktitle={NeurIPS},
year={2021}
}
@inproceedings{cheng2021mivos,
title={Modular Interactive Video Object Segmentation: Interaction-to-Mask, Propagation and Difference-Aware Fusion},
author={Cheng, Ho Kei and Tai, Yu-Wing and Tang, Chi-Keung},
booktitle={CVPR},
year={2021}
}
Metadata
Release files for stcnbuf 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stcnbuf-0.2.2.tar.gz | 21.0 kB | With provenance | Details for stcnbuf-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stcnbuf-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for stcnbuf-0.2.2-py3-none-any.whl |
Total release size: 43.0 kB
Release files / stcnbuf-0.2.2.tar.gz
| Download URL | stcnbuf-0.2.2.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5fa3f20f3ac676895c3ad376852d91c16ed981e0c2d1f598703549a0aa4ec45c
|
|
BLAKE2b-256 checksum How to use checksums |
7127dbc36ad4b37bb52aba898529680c3b763548b17eb253711700f8ed4c20d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logRelease files / stcnbuf-0.2.2-py3-none-any.whl
| Download URL | stcnbuf-0.2.2-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
386fc20ca0a0d21096c0fa924021316cde975d66d30e7901c9228609841f47cd
|
|
BLAKE2b-256 checksum How to use checksums |
1bd49546d0c440653b9ebeecd5359668e2bdc18a601164637947147b692973fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logSecurity for stcnbuf 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for stcnbuf-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.