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-10/

Image Background Removal Tool

Build a specialized image background removal tool that processes images from different domains using optimized models.

Requirements

Create a Python module that removes backgrounds from images while selecting the appropriate model based on image content type. The tool should support three specialized processing modes:

  1. Anime mode: For anime-style artwork and illustrations
  2. Portrait mode: For human portrait photographs
  3. Clothing mode: For fashion and apparel images

Core Functionality

Implement a function that:

  • Accepts an input image file path
  • Accepts a mode parameter (one of: "anime", "portrait", "clothing")
  • Processes the image to remove its background using the mode-appropriate model
  • Returns the processed image with transparent background
  • Saves the output to a specified file path

Model Selection

Different image types require different models for optimal results:

  • Anime illustrations benefit from high-accuracy anime-specific segmentation
  • Portrait photographs need models optimized for human features
  • Clothing items require specialized cloth parsing capabilities

Implementation Details

The function should:

  • Read the image from the provided file path
  • Apply background removal using the appropriate model for the specified mode
  • Handle errors gracefully (e.g., invalid file paths, unsupported modes)
  • Support common image formats (PNG, JPEG, JPG)

@generates

API

def remove_background(input_path: str, output_path: str, mode: str) -> None:
    """
    Remove background from an image using a specialized model.

    Args:
        input_path: Path to the input image file
        output_path: Path to save the output image with removed background
        mode: Processing mode - one of "anime", "portrait", or "clothing"

    Raises:
        ValueError: If mode is not one of the supported values
        FileNotFoundError: If input_path does not exist
    """
    pass

Test Cases

  • Processing an anime image with mode "anime" produces an output file with transparent background @test
  • Processing a portrait photo with mode "portrait" produces an output file with transparent background @test
  • Processing a clothing image with mode "clothing" produces an output file with transparent background @test
  • Calling the function with an unsupported mode raises ValueError @test

Dependencies { .dependencies }

rembg { .dependency }

Provides background removal capabilities with support for specialized AI models.

@satisfied-by

Version

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