Skip to content

[FEATURE] Add background removal command #2

Description

@Maelkiz

🚀 Feature Request

Add a new command simply rmbg <path-to-img> to remove backgrounds from images using AI-powered background removal.


🎯 Problem / Motivation

Background removal is a common image editing task. Adding this functionality would extend the CLI tool's capabilities and provide users with a convenient way to remove backgrounds without needing external tools or services.


💡 Proposed Solution

Implement the simply rmbg <path-to-img> command with the following approach:

  1. Use the rembg-rs crate - A Rust binding for the rembg library that provides background removal functionality
  2. Machine Learning Model: The implementation will use the U2-Net model (~280 MB) for background removal
  3. User Consent Flow: On the user's first use of the command:
    • Prompt the user asking if they are willing to download the ~280 MB U2-Net machine learning model
    • Only proceed with downloading and using the model if the user consents
    • Cache the model locally for subsequent uses
  4. Output: Save the image with the background removed (transparent background in PNG format)

✅ Acceptance Criteria

  • simply rmbg <path-to-img> command is implemented
  • The command uses the rembg-rs crate for background removal
  • User is prompted on first use to consent to downloading the ~280 MB U2-Net model
  • The ML model is cached locally after first download
  • The command successfully removes backgrounds from images
  • Output image has a transparent background (PNG format)
  • Error handling for invalid image paths and unsupported formats
  • Documentation is updated with usage examples

🧠 Notes / Context (if applicable)

  • rembg-rs crate: https://crates.io/crates/rembg-rs
  • U2-Net model: A deep learning model trained for salient object detection, commonly used for background removal
  • Consider adding a --force-download flag to allow users to re-download the model if needed
  • Consider adding output path customization with an optional --output flag

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions