
Jingyun Liang et al. / ETH Zurich (Apache 2.0)
Share this post:
BiRefNet, Real-ESRGAN & SwinIR: Open Source VFX Matting
Every visual effects shot and multi layer storyboard composite relies on two foundational utility passes, isolating foreground characters with clean alpha mattes and upscaling reference plates to 4K resolution without compression artifacts. Three lightweight open source models form the standard local compositing toolkit on consumer GPUs with 2 GB to 5.5 GB of VRAM. BiRefNet (developed by Peng Zheng et al. at Nankai University, Aalto University, Shanghai AI Laboratory, and University of Trento, published in CAAI AIR under an MIT license) performs high resolution dichotomous image segmentation (DIS) and trimap free alpha matting. SwinIR (developed by Jingyun Liang et al. at ETH Zurich under Apache 2.0) and Real-ESRGAN x4 (BSD-3-Clause) restore 4x spatial texture and remove JPEG compression noise prior to video generation.
Studio availability. BiRefNet and SwinIR are not available in AI FILMS Studio. This article covers a public research release. To generate images in the Studio, see the models listed on the AI background remover page.
Why Clean Plates and Alpha Mattes Matter in AI Filmmaking
Passing a raw 1024x1024 concept image directly into an image-to-video or character animation model often couples the actor to an unwanted background or magnifies latent softness during camera push ins. Separating a shot into foreground character layers and clean background plates gives directors three compositing advantages:
- Multi layer parallax and camera projection. Isolate foreground actors and mid ground props into transparent RGBA PNGs (
BiRefNet), project them onto 3D cards, or composite them over independently generated background plates. - Clean reference conditioning. Removing cluttered backgrounds before feeding a character portrait into a consistency or lip sync pipeline prevents background textures from bleeding into hair edges or shoulder motion.
- 4x pre upscale for crop and pan shots. Upscaling a 1024x1024 frame to 4096x4096 (
SwinIRorReal-ESRGAN x4) allows editors to reframe medium close ups and pan across high resolution matte paintings without pixelation.
BiRefNet: Bilateral Reference for High Resolution Segmentation
Traditional salient object detection networks downsample input images to 384x384 or 512x512, which obliterates fine boundary structures such as windblown hair, translucent veil fabric, wire rigging, and motion blurred fingers. BiRefNet (ZhengPeng7/BiRefNet, arXiv:2401.03407) operates natively at 1024x1024 up to 2048x2048 (BiRefNet_HR-matting) and dynamic resolutions (256x256 to 2304x2304) by combining two synergistic modules:
- Localization Module (
LM). Extracts global semantic context using a hierarchical vision transformer backbone (Swin-L) so the network identifies the complete foreground subject without fragmenting limbs or props. - Reconstruction Module (
RM) with Bilateral Reference. At each hierarchical decoding stage, BiRefNet feeds in two references simultaneously: inward reference (cropped patches of the original high resolution source image at matching spatial scales) and outward reference (gradient magnitude maps that highlight high frequency edge transitions).
Running in FP16 precision with PyTorch Scaled Dot Product Attention (SDPA), standard BiRefNet processes 1024x1024 frames at 17 FPS while consuming only 3.45 GB to 5.5 GB of VRAM, and its GPU foreground refinement pass (refine_foreground) completes in roughly 80 milliseconds.
SwinIR vs Real-ESRGAN x4 for 4x Plate Restoration
Once foreground elements or background plates are segmented, upscaling them by $4\times$ requires choosing between a transformer restoration architecture (SwinIR) and a perceptual GAN architecture (Real-ESRGAN x4):
SwinIR (Shifted Window Transformer)
Developed at ETH Zurich (arXiv:2108.10257), SwinIR replaces standard convolutional residual blocks with Residual Swin Transformer Blocks (RSTB). Each RSTB applies local window self attention alongside shifted window partitioning across consecutive layers, allowing the network to model long range structural dependencies (such as straight architectural lines, brick patterns, and lens grids) while keeping compute efficiency similar to CNNs. The large real world GAN checkpoint (003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth, 360 MB weights) requires 4 GB of VRAM and excels at deblocking compressed reference frames and restoring natural camera textures without hallucinating synthetic patterns.
Real-ESRGAN x4 (RRDB GAN)
Real-ESRGAN x4 (RealESRGAN_x4plus.pth, 67 MB weights, arXiv:2107.10833) uses a 23 block Residual in Residual Dense Block (RRDB) generator trained against synthetic second order degradations. It requires only 2 GB of VRAM and produces crisp, high contrast edges on concept art, matte paintings, and stylized 2D animation frames. For video timeline upscaling with the same architecture, see our guide on SeedVR2 and Real-ESRGAN Video upscaling, and for removing unwanted objects along with their cast shadows in video clips, see EffectErase video object removal.
Technical & Hardware Comparison
| Specification | BiRefNet (birefnet) |
SwinIR-Large x4 (swinir) |
Real-ESRGAN x4 (real-esrgan) |
|---|---|---|---|
| Primary Filmmaking Task | RGBA background removal & alpha matting | 4x image restoration & deblocking | Fast 4x spatial super resolution |
| Hugging Face / Source | ZhengPeng7/BiRefNet |
JingyunLiang/SwinIR |
ai-forever/Real-ESRGAN (xinntao/Real-ESRGAN) |
| Backbone Architecture | Swin-L + Bilateral Reference (LM + RM) |
Residual Swin Transformer Blocks (RSTB) |
23 block RRDB GAN + U-Net Discriminator |
| Minimum VRAM | 3.5 GB to 5.5 GB | 4 GB VRAM | 2 GB VRAM |
| Weight File Size | ~347 MB (model.safetensors) |
~360 MB (SwinIR-L_x4_GAN.pth) |
~67 MB (RealESRGAN_x4plus.pth) |
| License | MIT License | Apache 2.0 | BSD-3-Clause |
Running BiRefNet Locally in Python
BiRefNet loads in a single line through Hugging Face transformers (AutoModelForImageSegmentation) and exports a 32 bit RGBA PNG with a full transparency channel:
import torch
from PIL import Image
from torchvision import transforms
from transformers import AutoModelForImageSegmentation
birefnet = AutoModelForImageSegmentation.from_pretrained(
"ZhengPeng7/BiRefNet", trust_remote_code=True
).to("cuda").half().eval()
transform_image = transforms.Compose([
transforms.Resize((1024, 1024)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
image = Image.open("actor_plate.png").convert("RGB")
input_tensor = transform_image(image).unsqueeze(0).to("cuda").half()
with torch.no_grad():
alpha_pred = birefnet(input_tensor)[-1].sigmoid().cpu()[0].squeeze()
alpha_matte = transforms.ToPILImage()(alpha_pred).resize(image.size)
image.putalpha(alpha_matte)
image.save("actor_isolated_rgba.png")
Background Removal & 4x Image Upscaling in AI FILMS Studio
Filmmakers who want immediate browser based matting and 4x upscaling without managing local Python environments can run equivalent production models directly inside AI FILMS Studio:
- BEN2 Background Remover. Live on the AI Background Remover page and inside the Image Workspace for instant foreground isolation and alpha channel extraction. Follow our step by step BEN2 background remover tutorial for compositing tips.
- SeedVR Image Upscaler & Clarity AI Pro Upscaler. Live on the AI Image Upscaler page to scale concept frames and storyboards to 4K resolution.
- Nodes Graph Editor Compositing Chains. Inside the Nodes Graph Editor, you can connect a text-to-image node into BEN2 Background Remover to strip the background, pass the isolated subject into SeedVR Image Upscaler, and feed the crisp RGBA character plate directly into an image-to-video animation node.
Sources
BiRefNet Paper (arXiv:2401.03407 / CAAI AIR) | BiRefNet GitHub (ZhengPeng7/BiRefNet) | SwinIR Paper (arXiv:2108.10257 / ICCV) | Real-ESRGAN Paper (arXiv:2107.10833)
Continue Reading
Video & LipSync
- Video Generator
- Text to Video
- Image to Video
- Start-End Frame to Video
- Draw to Video
- Motion Control
- Video Enhancer
- Video Upscaler
- Video Extend
- Video to Video LipSync
- Audio to Video LipSync
- Image to Video LipSync
- Video FaceSwap
- Seedance 2.5
- WAN 3.0
- Seedance 2
- FLUX 3
- Minimax H3
- Vidu Q3 Pro
- Grok Imagine Video 1.5
- Gemini Omni
- Google Veo 3.1
- Kling 3.0 Pro
- Luma Ray 3.2
- LTX 2.3
- Happy Horse 1.1
- Kling 3.0 Motion
- ByteDance Upscaler
- InfiniteTalk
- InsightFace
Image & Edit
- AI Character
- AI Actor
- Art Generator
- Text to Image
- Image to Image
- LoRA Image to Image
- Draw to Edit
- Image LoRA Training
- Remove Background
- Image Enhancer
- MidJourney 8.0
- Krea 2
- OpenAI GPT Image 2.0
- Nano Banana Pro Ultra
- Nano Banana 2 Lite
- Nano Banana Pro
- Minimax Image
- Clarity Pro
- Z-Image Turbo LoRA
- Krea 2 Turbo LoRA
- Z-Image LoRA Trainer
- Qwen Image LoRA Trainer
- Background Erase Network 2 (BEN2)


