Ctrl + K
DocumentationLog inGet started

tessl/pypi-rembg

tessl install tessl/pypi-rembg@2.0.0

Remove 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%

task.mdevals/scenario-9/

GPU-Accelerated Image Background Remover

Build a command-line utility that removes backgrounds from images using hardware acceleration (GPU) when available, with automatic fallback to CPU processing.

Requirements

Hardware Acceleration Configuration

The utility should support configuring the execution provider for background removal processing. It should support three execution providers:

  • CUDA (for NVIDIA GPUs)
  • ROCm (for AMD GPUs)
  • CPU (fallback option)

The execution provider should be selectable via a command-line argument.

Fallback Mechanism

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.

Image Processing

The utility should process a single image file, remove its background, and save the result to a specified output path.

Implementation Requirements

@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 cuda

Where --provider can be cuda, rocm, or cpu.

Test Cases

  • Processing an image with CUDA provider specified uses GPU acceleration when available @test
  • When CUDA provider is specified but unavailable, the system falls back to CPU and prints a message @test
  • Processing an image with ROCm provider specified configures ROCm acceleration @test
  • Processing with CPU provider explicitly uses CPU execution @test

API

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.
    """
    pass

Dependencies { .dependencies }

rembg { .dependency }

Provides AI-powered background removal with GPU acceleration support.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/rembg@2.0.x
tile.json