Skip to content

SysAdminDoc/AlphaCut

Repository files navigation

AlphaCut v1.2.0

Video background removal & compositing.

AlphaCut uses ONNX segmentation models to isolate subjects from video backgrounds, with built-in compositing, batch processing.

Version Python License Platform


Features

AI & Processing

  • 8 AI Models β€” U2Net, ISNet, BiRefNet β€” from fast drafts to cinema-quality edges
  • 7 Output Formats β€” ProRes 4444+Alpha, WebM VP9+Alpha, Animated WebP, Animated GIF, PNG sequences, green screen, grayscale matte
  • Chroma-Key Fallback β€” auto-detect green/blue screens; FFmpeg chroma-key for 10x speed boost
  • Pipelined I/O β€” parallel decode/infer/save threads for higher throughput
  • Frame Skip β€” process every Nth frame with mask reuse (up to 10x speedup)
  • Benchmark Mode β€” test 10 samples to estimate total processing time
  • Memory Monitoring β€” live RAM % during processing with warnings
  • Resume Interrupted Jobs β€” progress saved every 50 frames, auto-resumes on restart

Advanced Compositing

  • Background Replacement β€” solid color (6 presets + custom picker) or image file
  • Color Spill Suppression β€” reduce green/blue/red spill along mask edges
  • Shadow Preservation β€” detect and keep ground shadows via luminance analysis
  • Mask Inversion β€” remove subject instead of background

Batch & Workflow

  • Batch Queue β€” drop multiple files or a folder, process sequentially
  • Job Table β€” per-file thumbnails, status, progress %, and output path
  • CLI Mode β€” full argparse interface for headless/scripted operation (with auto chroma-key detection)
  • Auto-Naming β€” configurable output patterns ({name}, {model}, {format}, {date})
  • Export Presets β€” save/load all settings including compositing
  • Recent Files β€” last 20 files quick-access menu

UI/UX

  • Before/After Split View with draggable divider
  • Smart Model Picker, Toast Notifications, Animated Progress
  • System Tray integration, Scrubable Preview
  • Menu Bar β€” File, Tools (Model Manager, Settings Folder), Help (Updates, About)
  • About Dialog β€” version, system info, GitHub links
  • Update Checker β€” checks GitHub releases on startup and on demand
  • Model Manager β€” view/delete cached ONNX models with size info
  • Settings Persistence β€” all preferences saved between sessions

Requirements

Requirement Details
Python 3.9+
FFmpeg On PATH
NVIDIA GPU Optional β€” CUDA 12 + cuDNN 9

Quick Start

# GUI
python AlphaCut.py

# CLI β€” basic
python AlphaCut.py -i video.mp4 -f prores -m BiRefNet

# CLI β€” background replacement
python AlphaCut.py -i video.mp4 -f webm --bg-image beach.jpg

# CLI β€” green spill + shadow preservation
python AlphaCut.py -i greenscreen.mp4 -f prores --spill 60 --shadow 40

# CLI β€” batch with frame skip
python AlphaCut.py -i vid1.mp4 vid2.mp4 vid3.mp4 -f webm --frame-skip 3

# CLI β€” invert mask + custom background
python AlphaCut.py -i video.mp4 -f prores --invert --bg-color 0,0,0

CLI Reference

Flag Default Description
-i, --input β€” Input video file(s)
-o, --output Auto-named Output path
-m, --model u2net_human_seg Model name (partial match)
-f, --format mp4 mp4, prores, webm, webp_anim, png_seq, greenscreen, matte
--max-res 0 (original) Max resolution
--edge 0 Edge softness (0-100)
--shift 0 Mask shift (-20 to +20)
--temporal 0 Temporal smooth (0-7)
--frame-skip 1 Process every Nth frame
--invert β€” Invert mask
--spill 0 Spill suppression (0-100)
--spill-color green Spill color: green, blue, red
--shadow 0 Shadow preservation (0-100)
--bg-color β€” Background R,G,B
--bg-image β€” Background image path
--no-audio β€” Strip audio

AI Models

Model Speed Quality Best For
u2netp Fast Good Quick previews
u2net_human_seg Fast Great People (default)
silueta Fast Good People (small)
u2net Medium Great General subjects
isnet-general-use Medium Great General subjects
isnet-anime Medium Great Anime / illustrations
BiRefNet-portrait Slow Excellent Portraits, hair detail
BiRefNet-general Slow Excellent Best overall

Architecture

AlphaCut.py (single file, ~2,650 lines)
β”œβ”€β”€ Crash Handler + Bootstrap (auto-installs all deps)
β”œβ”€β”€ AlphaCutEngine β€” ONNX inference + mask refinement
β”‚   β”œβ”€β”€ Edge refinement, temporal smoothing
β”‚   β”œβ”€β”€ Spill suppression, shadow preservation
β”‚   β”œβ”€β”€ Mask inversion, background compositing
β”‚   β”œβ”€β”€ SHA-256 model integrity verification
β”‚   └── Engine cache (singleton)
β”œβ”€β”€ ProcessingWorker β€” Pipelined frame processing
β”‚   β”œβ”€β”€ Reader thread β†’ AI inference β†’ Saver thread
β”‚   β”œβ”€β”€ Frame skip with mask reuse
β”‚   └── Resume from last saved frame
β”œβ”€β”€ BatchWorker β€” Sequential multi-file processing
β”œβ”€β”€ BenchmarkWorker β€” 10-frame speed estimation
β”œβ”€β”€ PreviewFrameWorker β€” Single-frame preview
β”œβ”€β”€ UpdateChecker β€” GitHub releases API
β”œβ”€β”€ AboutDialog β€” Version/system info
β”œβ”€β”€ ModelManagerDialog β€” Download/delete models
β”œβ”€β”€ SplitPreviewWidget β€” Before/after comparison
β”œβ”€β”€ ToastWidget β€” Floating notifications
β”œβ”€β”€ CLI β€” Full argparse headless interface
└── Settings/Presets β€” JSON persistence

About

Video background removal & compositing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages