MogensR's picture
Update README.md
9adb277
|
raw
history blame
5.58 kB
metadata
title: BackgroundFX Fast
emoji: πŸš€
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
license: mit
models:
  - rembg/u2net_human_seg
hardware: T4 medium

πŸš€ BackgroundFX - Lightning-Fast Video Background Replacement

Professional-quality background replacement in seconds, not minutes! Powered by specialized AI models optimized for T4 GPU performance.

Hugging Face Spaces GPU Optimized

⚑ Performance Benchmarks

Video Length Ultra Fast Fast Balanced Quality
10 seconds 5 sec 10 sec 15 sec 20 sec
30 seconds 15 sec 30 sec 45 sec 60 sec
60 seconds 30 sec 60 sec 90 sec 120 sec

Benchmarks on T4 GPU with 1080p video

🎯 Key Features

πŸƒβ€β™‚οΈ Speed-First Design

  • 5-10x faster than SAM2-based solutions
  • Optimized for T4 GPU on Hugging Face Spaces
  • Real-time preview of first frame
  • Batch processing for maximum efficiency

🎨 Intelligent Segmentation

  • Rembg U2NET: Purpose-built for human segmentation (92-95% accuracy)
  • MatAnyone Integration: Optional edge refinement for hair and clothing
  • Automatic fallback: Works even without GPU

🎬 Flexible Processing Modes

  • Ultra Fast: Every 3rd frame, direct compositing (3x speed)
  • Fast: Every 2nd frame (2x speed)
  • Balanced: All frames, optimized pipeline
  • Quality: Full processing with green screen workflow

πŸ–ΌοΈ Background Options

  • Gradient backgrounds: Instant generation
  • Solid colors: Simple and clean
  • Image URL: Direct from web
  • Upload: Your own images

πŸ”§ Technology Stack

Pipeline: Rembg β†’ MatAnyone (optional) β†’ Compositing β†’ Output
Component Purpose Performance Impact
Rembg Person extraction Base speed
U2NET_human_seg Specialized human model Optimized for people
MatAnyone Edge refinement +20% time, better edges
OpenCV Video processing Hardware accelerated
Torch GPU acceleration 5-10x speedup

πŸ“¦ Installation

Quick Deploy to Hugging Face Spaces

  1. Clone this repository
  2. Create new Space on Hugging Face
  3. Select T4 GPU (medium or small)
  4. Push code and wait for build

Requirements

streamlit==1.48.0
opencv-python-headless
numpy
Pillow
rembg
torch
torchvision
onnxruntime-gpu
matanyone  # Optional: for edge refinement

πŸš€ Usage

Simple 3-Step Process

  1. Upload Video πŸ“Ή

    • Supports MP4, AVI, MOV, MKV
    • Recommended: Under 30 seconds for fastest processing
  2. Choose Background 🎨

    • Gradient: Instant custom gradients
    • Color: Solid color backgrounds
    • Image: URL or upload
  3. Select Speed & Process ⚑

    • Pick your speed/quality tradeoff
    • Optional MatAnyone refinement
    • Download result

🎯 Use Cases

  • Content Creation: YouTube, TikTok, Instagram videos
  • Professional: Video calls, presentations, demos
  • Education: Online courses, tutorials
  • Marketing: Product videos, advertisements
  • Personal: Fun videos, memes, creative content

πŸ—οΈ Architecture Decisions

Why Rembg over SAM2?

Aspect Rembg SAM2
Human Segmentation 92-95% accuracy 85-90% accuracy
Speed 15-20 FPS 2-3 FPS
Memory 500MB-1GB 2-4GB
Setup Simple Complex
Purpose Specialized for humans General purpose

Why MatAnyone?

  • Refines edges around hair and clothing
  • Minimal performance impact (20%)
  • Optional - can disable for speed
  • Professional-quality output

πŸ“Š Performance Optimization Tips

  1. For fastest processing:

    • Use "Ultra Fast" mode
    • Disable MatAnyone
    • Use gradient backgrounds
    • Keep videos under 30 seconds
  2. For best quality:

    • Use "Quality" mode
    • Enable MatAnyone
    • Use green screen workflow
    • Process at full resolution
  3. For best balance:

    • Use "Fast" mode
    • Enable MatAnyone for important videos
    • Gradient or simple backgrounds

πŸ› Troubleshooting

Issue Solution
Slow processing Switch to "Fast" or "Ultra Fast" mode
GPU not detected Ensure T4 GPU is enabled in Space settings
Out of memory Use "Ultra Fast" mode or shorter videos
Poor edges Enable MatAnyone refinement
Video won't play Check video codec compatibility

πŸ“ˆ Roadmap

  • Batch video processing
  • Custom model fine-tuning
  • Real-time preview
  • Mobile app
  • API endpoint
  • More background effects

🀝 Contributing

Contributions welcome! Please check our guidelines.

πŸ“„ License

MIT License - feel free to use in your projects!

πŸ™ Acknowledgments

  • Rembg team for the excellent segmentation models
  • MatAnyone for edge refinement technology
  • Hugging Face for GPU infrastructure
  • Streamlit for the amazing framework

πŸ’¬ Support


Built for speed, designed for quality. πŸš€

Optimized for T4 GPU on Hugging Face Spaces