Image background removal tool supporting U2Net and CascadePSP models
Project description
clipx
English | 简体中文
Introduction
clipx is an open-source Python library designed for quick and flexible image background removal. It supports both command-line interface (CLI) and Python API usage. Currently, it integrates two image segmentation models, U2Net and CascadePSP, which can be used individually or combined for enhanced performance. Additionally, clipx has an extensible architecture, making it easy to incorporate additional models in the future.
Installation
pip install clipx
CLI Examples
- Generate transparent image using combined mode (U2Net + CascadePSP):
clipx -i input.jpg
- Specify output path:
clipx -i input.jpg -o output.png
- Use fast mode for CascadePSP (faster but less accurate):
clipx -i input.jpg -o output.png --fast
- Use U2Net only for mask generation:
clipx -i input.jpg -o output.png -m u2net
- Enable debug logging:
clipx -i input.jpg --debug
Python API Example
# Import the background removal function
from clipx import remove_background
# Remove the background from an image with a single line of code
result = remove_background("photo.jpg")
print(f"Image with background removed saved to: {result}")
Advanced Usage
Logging Configuration
You can configure the logging level:
from clipx import set_log_level, enable_console_logging
import logging
# Enable console logging
enable_console_logging()
# Set log level
set_log_level(logging.DEBUG)
Acknowledgements and Code Sources
The image segmentation models in clipx are based on the following projects:
- U2Net: U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection
- CascadePSP: CascadePSP: Toward Class-Agnostic and Very High-Resolution Segmentation via Global and Local Refinement
We greatly appreciate the original authors' work and contributions.
License
This project is licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clipx-0.3.0.tar.gz.
File metadata
- Download URL: clipx-0.3.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81e16b539421b5cee5f426d18e81fe1d7c4f80259e9d88120ad223ab1bffd020
|
|
| MD5 |
e91ec0fc4a440966e6319bd2ef15de7e
|
|
| BLAKE2b-256 |
33f819d767fa9f87a7d45f6a9e7e7ab508137a4ee446e858ef66de0632c4eec8
|
File details
Details for the file clipx-0.3.0-py3-none-any.whl.
File metadata
- Download URL: clipx-0.3.0-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56153739632d3ddcfe5ad53e5933a1fe26eea4c846436c23f19560721a2a622e
|
|
| MD5 |
3bd43a6c3a202be9751ee0ef4a993b22
|
|
| BLAKE2b-256 |
ba4cdaf5bb081d125e150961b8615e64eba54e253bc3b20455b28436650ef763
|