ViTMatte

This is a demo of ViTMatte, an image matting method that uses Vision Transformers (ViT) to accurately extract the foreground from an image. It predicts a soft alpha matte to help separate the subject from the background — even tricky areas like hair and fur!

You've got two ways to get started:

🖼️ Option 1: Upload Image & Trimap

  • Upload your original image.
  • Upload a trimap: a helper image that labels regions as foreground (white), background (black), and unknown (gray).
  • The trimap must be a grayscale image containing only three pixel values:
    • 0 for background
    • 128 for unknown
    • 255 for foreground
  • The model will use this trimap to generate the alpha matte and extract the foreground.

✏️ Option 2: Draw Your Own Trimap

  • Upload just your image.
  • Go to the "Draw Trimap" tab to start drawing masks.
  • Use the tools to mark:
    • Foreground (e.g. the subject),
    • Unknown (areas where the boundary is unclear).
  • Once you're done, click the "Generate Trimap" button to generate the trimap from your drawing.

✨ Optional: Replace Background

Want to swap the background? Just check the "Replace Background" option and choose a new background image. The app will blend your extracted subject with the new background seamlessly!

Examples
Input image Trimap Replace background Background image