tessl install tessl/pypi-rembg@2.0.0Remove image background using advanced AI models including U-Net, BiRefNet, and SAM with support for multiple input formats and GPU acceleration
Agent Success
Agent success rate when using this tile
84%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.94x
Baseline
Agent success rate without this tile
89%
Build a command-line utility that removes backgrounds from images using hardware acceleration (GPU) when available, with automatic fallback to CPU processing.
The utility should support configuring the execution provider for background removal processing. It should support three execution providers:
The execution provider should be selectable via a command-line argument.
If the specified GPU provider (CUDA or ROCm) is not available on the system, the utility should automatically fall back to CPU processing and inform the user which provider is being used.
The utility should process a single image file, remove its background, and save the result to a specified output path.
@generates
Create a Python script that can be run from the command line with the following interface:
python gpu_remover.py --input image.jpg --output result.png --provider cudaWhere --provider can be cuda, rocm, or cpu.
from pathlib import Path
from typing import Tuple
def create_session(provider: str):
"""
Create a processing session configured with the specified execution provider.
Handles fallback to CPU if the specified GPU provider is unavailable.
Args:
provider: One of 'cuda', 'rocm', or 'cpu'
Returns:
A configured session object and the actual provider being used
"""
pass
def remove_background(input_path: Path, output_path: Path, provider: str) -> str:
"""
Remove background from an image using the specified execution provider.
Args:
input_path: Path to input image file
output_path: Path where output image will be saved
provider: Execution provider preference ('cuda', 'rocm', or 'cpu')
Returns:
The execution provider that was actually used
"""
pass
def main():
"""
Main entry point for the command-line interface.
Parses arguments and processes the image.
"""
passProvides AI-powered background removal with GPU acceleration support.