Metadata-Version: 2.4
Name: remove-background
Version: 0.1.0
Summary: Fast, minimal background removal using ONNX segmentation models
Author: Mehedi Hasan
Author-email: Mehedi Hasan <huzzat2@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Dist: onnxruntime>=1.17.0
Requires-Dist: pillow>=10.0.0
Requires-Dist: numpy>=1.24.0
Requires-Python: >=3.9
Project-URL: Homepage, https://github.com/devusimple/remove_background
Project-URL: Issues, https://github.com/devusimple/remove_background/issues
Description-Content-Type: text/markdown

# remove-background

Fast, minimal background removal for Python using ONNX segmentation models.

## Features

- Uses ONNX Runtime for fast inference (CPU)
- Minimal dependencies: only `onnxruntime`, `Pillow`, `numpy`
- Core image preprocessing and postprocessing written from scratch
- Python API and CLI
- Works with any ONNX segmentation model (ISNet, U2-Net, etc.)

## Installation

```bash
pip install remove-background
```

The import name is `remove_background`:

## Usage

### Python API

```python
from remove_background import remove_background, get_mask

# Remove background (returns RGBA image)
result = remove_background("input.jpg", model_path="model.onnx")
result.save("output.png")

# Get mask only (returns grayscale image)
mask = get_mask("input.jpg", model_path="model.onnx")
mask.save("mask.png")
```

### CLI

```bash
# Remove background
python -m remove_background input.jpg -o output.png -m model.onnx

# Get mask only
python -m remove_background input.jpg --mask-only -m model.onnx
```

## Model Setup

Download an ONNX segmentation model (e.g., ISNet or U2-Net) and place it in your working directory, or pass `model_path` explicitly.

The model must:
- Accept input shape `(1, 3, H, W)` float32
- Output a segmentation mask `(1, 1, H, W)` or `(1, H, W)`

## License

MIT
