Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Putting the Object Back into Video Object Segmentation

Fork notice: This fork packages and maintains Cutie for reliable installation and PyPI releases, while preserving the upstream project's research attribution and documentation.

Ho Kei Cheng, Seoung Wug Oh, Brian Price, Joon-Young Lee, Alexander Schwing

University of Illinois Urbana-Champaign and Adobe

CVPR 2024, Highlight

[arXiV] [PDF] [Project Page] Open In Colab

Highlight

Cutie is a video object segmentation framework -- a follow-up work of XMem with better consistency, robustness, and speed. This repository contains code for standard video object segmentation and a GUI tool for interactive video segmentation. The GUI tool additionally contains the "permanent memory" (from XMem++) option for better controllability.

overview

Demo Video

https://github.com/hkchengrex/Cutie/assets/7107196/83a8abd5-369e-41a9-bb91-d9cc1289af70

Source: https://raw.githubusercontent.com/hkchengrex/Cutie/main/docs/sources.txt

Installation

Tested on Ubuntu only.

Prerequisite:

  • Python 3.10+
  • A PyTorch build for your hardware; image profiles also require matching torchvision

Clone our repository:

git clone https://github.com/hkchengrex/Cutie.git

Install the model core with pip:

cd Cutie
pip install -e .

Install feature-specific dependencies only when needed:

Profile Command Use case
Inference pip install -e '.[inference]' Scripting examples and default model download.
Evaluation pip install -e '.[evaluation]' cutie/eval_vos.py, BURST, and multi-scale score outputs.
Training pip install -e '.[train]' Distributed training.
GUI pip install -e '.[gui]' Interactive desktop tool from a source checkout.
Video pip install -e '.[video]' scripts/process_video.py.
Data pip install -e '.[data]' Dataset conversion and multi-scale utility scripts.

The core package contains only the model dependencies. Choose a PyTorch and torchvision build compatible with your CPU, CUDA, or MPS environment before installing a profile that requires image transforms.

Download the pretrained models:

python cutie/utils/download_models.py

Quick Start

Scripting Demo

This is probably the best starting point if you want to use Cutie in your project. Hopefully, the script is self-explanatory (additional comments in scripting_demo.py). If not, feel free to open an issue. For more advanced usage, like adding or removing objects, see scripting_demo_add_del_objects.py.

@torch.inference_mode()
@torch.cuda.amp.autocast()
def main():

    cutie = get_default_model()
    processor = InferenceCore(cutie, cfg=cutie.cfg)
    # the processor matches the shorter edge of the input to this size
    # you might want to experiment with different sizes, -1 keeps the original size
    processor.max_internal_size = 480

    image_path = './examples/images/bike'
    images = sorted(os.listdir(image_path))  # ordering is important
    mask = Image.open('./examples/masks/bike/00000.png')
    palette = mask.getpalette()
    objects = np.unique(np.array(mask))
    objects = objects[objects != 0].tolist()  # background "0" does not count as an object
    mask = torch.from_numpy(np.array(mask)).cuda()

    for ti, image_name in enumerate(images):
        image = Image.open(os.path.join(image_path, image_name))
        image = to_tensor(image).cuda().float()

        if ti == 0:
            output_prob = processor.step(image, mask, objects=objects)
        else:
            output_prob = processor.step(image)

        # convert output probabilities to an object mask
        mask = processor.output_prob_to_mask(output_prob)

        # visualize prediction
        mask = Image.fromarray(mask.cpu().numpy().astype(np.uint8))
        mask.putpalette(palette)
        mask.show()  # or use mask.save(...) to save it somewhere


main()

Interactive Demo

Start the interactive demo with:

python interactive_demo.py --video ./examples/example.mp4 --num_objects 1

See more instructions here. If you are running this on a remote server, X11 forwarding is possible. Start by using ssh -X. Additional configurations might be needed but Google would be more helpful than me.

demo

(For single video evaluation, see the unofficial script scripts/process_video.py from https://github.com/hkchengrex/Cutie/pull/16)

Training and Evaluation

  1. Running Cutie on video object segmentation data.
  2. Training Cutie.

Citation

@inproceedings{cheng2023putting,
  title={Putting the Object Back into Video Object Segmentation},
  author={Cheng, Ho Kei and Oh, Seoung Wug and Price, Brian and Lee, Joon-Young and Schwing, Alexander},
  booktitle={arXiv},
  year={2023}
}

References

  • The GUI tools uses RITM for interactive image segmentation. This repository also contains a redistribution of their code in gui/ritm. That part of code follows RITM's license.

  • For automatic video segmentation/integration with external detectors, see DEVA.

  • The interactive demo is developed upon IVS, MiVOS, and XMem.

  • We used ProPainter in our video inpainting demo.

  • Thanks to RTIM and XMem++ for making this possible.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rf_cutie-1.0.0rc2.tar.gz (158.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rf_cutie-1.0.0rc2-py3-none-any.whl (171.5 kB view details)

Uploaded Python 3

File details

Details for the file rf_cutie-1.0.0rc2.tar.gz.

File metadata

  • Download URL: rf_cutie-1.0.0rc2.tar.gz
  • Upload date:
  • Size: 158.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for rf_cutie-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 48c6e964a6b86f90ff5921c08cfee871071f3d65be91069c6bf1e5b467c25bf3
MD5 8b257c44bc2fc5213051fa5d0c1b2384
BLAKE2b-256 22d95bdb1590e7883a666d222ae6de4483188eddbe4c6805cbc67564c8a7736b

See more details on using hashes here.

File details

Details for the file rf_cutie-1.0.0rc2-py3-none-any.whl.

File metadata

  • Download URL: rf_cutie-1.0.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 171.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for rf_cutie-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff6032fa9384f4d61c8cc8d793b8b6c313d55a0a39e4a91c80e065a9b3bd6c2d
MD5 a963b9866a91bcdf7c2cf9ba3076d632
BLAKE2b-256 93f56deeab355b344dc33660a96d05316e4baa05f8cfb03888be05b4d9207691

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page