[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2347":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},2347,"rembg","danielgatis\u002Frembg","danielgatis","Rembg is a tool to remove images background","",null,"Python",23276,2322,168,1,0,15,90,355,76,45,"MIT License",false,"main",[26,27,28],"background-removal","image-processing","python","2026-06-12 02:00:40","\u003Cp align=\"center\">\n  \u003Cimg src=\"logo.png\" alt=\"Rembg Logo\" width=\"600\" \u002F>\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n  \u003Cp align=\"center\">Rembg is a tool to remove image backgrounds. It can be used as a CLI, Python library, HTTP server, or Docker container.\u003C\u002Fp>\n  \u003Cdiv style=\"display: flex; flex-direction: row; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px;\">\n    \u003Ca href=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue.svg\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue.svg\" alt=\"License\" \u002F>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FKenjieDec\u002FRemBG\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🤗%20Hugging%20Face-Spaces-blue\" alt=\"Hugging Face Spaces\" \u002F>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fbgremoval.streamlit.app\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🎈%20Streamlit%20Community-Cloud-blue\" alt=\"Streamlit App\" \u002F>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdanielgatis\u002Frembg\u002Fblob\u002Fmain\u002Frembg.ipynb\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"Open in Colab\" \u002F>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Frepomapr.com\u002Fdanielgatis\u002Frembg\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FRepoMapr-View_Interactive_Diagram-blue?style=flat&logo=github\" alt=\"RepoMapr\" \u002F>\u003C\u002Fa>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\u003Cbr\u002F>\n\n\u003Cp align=\"center\">\n    \u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F2846\" target=\"_blank\">\n        \u003Cimg src=\"https:\u002F\u002Ftrendshift.io\u002Fapi\u002Fbadge\u002Frepositories\u002F2846\" alt=\"danielgatis%2Frembg | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\n    \u003C\u002Fa>\n\u003C\u002Fp>\n\n## Sponsors\n\n\u003Ctable>\n \u003Ctr>\n    \u003Ctd align=\"center\" vertical-align=\"center\">\n      \u003Ca href=\"https:\u002F\u002Fphotoroom.com\u002Fapi\u002Fremove-background?utm_source=rembg&utm_medium=github_webpage&utm_campaign=sponsor\" >\n        \u003Cimg src=\"https:\u002F\u002Ffont-cdn.photoroom.com\u002Fmedia\u002Fapi-logo.png\" width=\"120px;\" alt=\"Unsplash\" \u002F>\n      \u003C\u002Fa>\n    \u003C\u002Ftd>\n    \u003Ctd align=\"center\" vertical-align=\"center\">\n      \u003Cb>PhotoRoom Remove Background API\u003C\u002Fb>\n      \u003Cbr \u002F>\n      \u003Ca href=\"https:\u002F\u002Fphotoroom.com\u002Fapi\u002Fremove-background?utm_source=rembg&utm_medium=github_webpage&utm_campaign=sponsor\">https:\u002F\u002Fphotoroom.com\u002Fapi\u003C\u002Fa>\n      \u003Cbr \u002F>\n      \u003Cp width=\"200px\">\n        Fast and accurate background remover API\u003Cbr\u002F>\n      \u003C\u002Fp>\n    \u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n**If this project has helped you, please consider making a [donation](https:\u002F\u002Fwww.buymeacoffee.com\u002Fdanielgatis).**\n\n## Requirements\n\n```text\npython: >=3.11, \u003C3.14\n```\n\n## Installation\n\nChoose **one** of the following backends based on your hardware:\n\n### CPU support\n\n```bash\npip install \"rembg[cpu]\" # for library\npip install \"rembg[cpu,cli]\" # for library + cli\n```\n\n### GPU support (NVIDIA\u002FCUDA)\n\nFirst, check if your system supports `onnxruntime-gpu` by visiting [onnxruntime.ai](https:\u002F\u002Fonnxruntime.ai\u002Fgetting-started) and reviewing the installation matrix.\n\n\u003Cp style=\"display: flex;align-items: center;justify-content: center;\">\n  \u003Cimg alt=\"onnxruntime-installation-matrix\" src=\".\u002Fonnxruntime-installation-matrix.png\" width=\"400\" \u002F>\n\u003C\u002Fp>\n\nIf your system is compatible, run:\n\n```bash\npip install \"rembg[gpu]\" # for library\npip install \"rembg[gpu,cli]\" # for library + cli\n```\n\n> **Note:** NVIDIA GPUs may require `onnxruntime-gpu`, CUDA, and `cudnn-devel`. See [#668](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Fissues\u002F668#issuecomment-2689830314) for details. If `rembg[gpu]` doesn't work and you can't install CUDA or `cudnn-devel`, use `rembg[cpu]` with `onnxruntime` instead.\n\n### GPU support (AMD\u002FROCm)\n\nROCm support requires the `onnxruntime-rocm` package. Install it by following [AMD's documentation](https:\u002F\u002Frocm.docs.amd.com\u002Fprojects\u002Fradeon\u002Fen\u002Flatest\u002Fdocs\u002Finstall\u002Fnative_linux\u002Finstall-onnx.html).\n\nOnce `onnxruntime-rocm` is installed and working, install rembg with ROCm support:\n\n```bash\npip install \"rembg[rocm]\" # for library\npip install \"rembg[rocm,cli]\" # for library + cli\n```\n\n## Usage as a CLI\n\nAfter installation, you can use rembg by typing `rembg` in your terminal.\n\nThe `rembg` command has 4 subcommands, one for each input type:\n\n- `i` - single files\n- `p` - folders (batch processing)\n- `s` - HTTP server\n- `b` - RGB24 pixel binary stream\n\nYou can get help about the main command using:\n\n```shell\nrembg --help\n```\n\nYou can also get help for any subcommand:\n\n```shell\nrembg \u003CCOMMAND> --help\n```\n\n### rembg `i`\n\nUsed for processing single files.\n\n**Remove background from a remote image:**\n\n```shell\ncurl -s http:\u002F\u002Finput.png | rembg i > output.png\n```\n\n**Remove background from a local file:**\n\n```shell\nrembg i path\u002Fto\u002Finput.png path\u002Fto\u002Foutput.png\n```\n\n**Specify a model:**\n\n```shell\nrembg i -m u2netp path\u002Fto\u002Finput.png path\u002Fto\u002Foutput.png\n```\n\n**Return only the mask:**\n\n```shell\nrembg i -om path\u002Fto\u002Finput.png path\u002Fto\u002Foutput.png\n```\n\n**Apply alpha matting:**\n\n```shell\nrembg i -a path\u002Fto\u002Finput.png path\u002Fto\u002Foutput.png\n```\n\n**Pass extra parameters (SAM example):**\n\n```shell\nrembg i -m sam -x '{ \"sam_prompt\": [{\"type\": \"point\", \"data\": [724, 740], \"label\": 1}] }' examples\u002Fplants-1.jpg examples\u002Fplants-1.out.png\n```\n\n**Pass extra parameters (custom model):**\n\n```shell\nrembg i -m u2net_custom -x '{\"model_path\": \"~\u002F.u2net\u002Fu2net.onnx\"}' path\u002Fto\u002Finput.png path\u002Fto\u002Foutput.png\n```\n\n### rembg `p`\n\nUsed for batch processing entire folders.\n\n**Process all images in a folder:**\n\n```shell\nrembg p path\u002Fto\u002Finput path\u002Fto\u002Foutput\n```\n\n**Watch mode (process new\u002Fchanged files automatically):**\n\n```shell\nrembg p -w path\u002Fto\u002Finput path\u002Fto\u002Foutput\n```\n\n### rembg `s`\n\nUsed to start an HTTP server.\n\n```shell\nrembg s --host 0.0.0.0 --port 7000 --log_level info\n```\n\nFor complete API documentation, visit: `http:\u002F\u002Flocalhost:7000\u002Fapi`\n\n**Disable the Gradio UI (reduces idle CPU usage):**\n\n```shell\nrembg s --no-ui\n```\n\n**Remove background from an image URL:**\n\n```shell\ncurl -s \"http:\u002F\u002Flocalhost:7000\u002Fapi\u002Fremove?url=http:\u002F\u002Finput.png\" -o output.png\n```\n\n**Remove background from an uploaded image:**\n\n```shell\ncurl -s -F file=@\u002Fpath\u002Fto\u002Finput.jpg \"http:\u002F\u002Flocalhost:7000\u002Fapi\u002Fremove\" -o output.png\n```\n\n### rembg `b`\n\nProcess a sequence of RGB24 images from stdin. This is intended to be used with programs like FFmpeg that output RGB24 pixel data to stdout.\n\n```shell\nrembg b \u003Cwidth> \u003Cheight> -o \u003Coutput_specifier>\n```\n\n**Arguments:**\n\n| Argument | Description |\n|----------|-------------|\n| `width` | Width of input image(s) |\n| `height` | Height of input image(s) |\n| `output_specifier` | Printf-style specifier for output filenames (e.g., `output-%03u.png` produces `output-000.png`, `output-001.png`, etc.). Omit to write to stdout. |\n\n**Example with FFmpeg:**\n\n```shell\nffmpeg -i input.mp4 -ss 10 -an -f rawvideo -pix_fmt rgb24 pipe:1 | rembg b 1280 720 -o folder\u002Foutput-%03u.png\n```\n\n> **Note:** The width and height must match FFmpeg's output dimensions. The flags `-an -f rawvideo -pix_fmt rgb24 pipe:1` are required for FFmpeg compatibility.\n\n## Usage as a Library\n\n**Input and output as bytes:**\n\n```python\nfrom rembg import remove\n\nwith open('input.png', 'rb') as i:\n    with open('output.png', 'wb') as o:\n        input = i.read()\n        output = remove(input)\n        o.write(output)\n```\n\n**Input and output as a PIL image:**\n\n```python\nfrom rembg import remove\nfrom PIL import Image\n\ninput = Image.open('input.png')\noutput = remove(input)\noutput.save('output.png')\n```\n\n**Input and output as a NumPy array:**\n\n```python\nfrom rembg import remove\nimport cv2\n\ninput = cv2.imread('input.png')\noutput = remove(input)\ncv2.imwrite('output.png', output)\n```\n\n**Force output as bytes:**\n\n```python\nfrom rembg import remove\n\nwith open('input.png', 'rb') as i:\n    with open('output.png', 'wb') as o:\n        input = i.read()\n        output = remove(input, force_return_bytes=True)\n        o.write(output)\n```\n\n**Batch processing with session reuse (recommended for performance):**\n\n```python\nfrom pathlib import Path\nfrom rembg import remove, new_session\n\nsession = new_session()\n\nfor file in Path('path\u002Fto\u002Ffolder').glob('*.png'):\n    input_path = str(file)\n    output_path = str(file.parent \u002F (file.stem + \".out.png\"))\n\n    with open(input_path, 'rb') as i:\n        with open(output_path, 'wb') as o:\n            input = i.read()\n            output = remove(input, session=session)\n            o.write(output)\n```\n\nFor more examples, see the [examples](USAGE.md) page.\n\n## Usage with Docker\n\n### CPU Only\n\nReplace the `rembg` command with `docker run danielgatis\u002Frembg`:\n\n```shell\ndocker run -v .:\u002Fdata danielgatis\u002Frembg i \u002Fdata\u002Finput.png \u002Fdata\u002Foutput.png\n```\n\n### NVIDIA CUDA GPU Acceleration\n\n**Requirements:** Your host must have the [NVIDIA Container Toolkit](https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html) installed.\n\nCUDA acceleration requires `cudnn-devel`, so you need to build the Docker image yourself. See [#668](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Fissues\u002F668#issuecomment-2689914205) for details.\n\n**Build the image:**\n\n```shell\ndocker build -t rembg-nvidia-cuda-cudnn-gpu -f Dockerfile_nvidia_cuda_cudnn_gpu .\n```\n\n> **Note:** This image requires ~11GB of disk space (CPU version is ~1.6GB). Models are not included.\n\n**Run the container:**\n\n```shell\nsudo docker run --rm -it --gpus all -v \u002Fdev\u002Fdri:\u002Fdev\u002Fdri -v $PWD:\u002Fdata rembg-nvidia-cuda-cudnn-gpu i -m birefnet-general \u002Fdata\u002Finput.png \u002Fdata\u002Foutput.png\n```\n\n**Tips:**\n\n- You can create your own NVIDIA CUDA image and install `rembg[gpu,cli]` in it.\n- Use `-v \u002Fpath\u002Fto\u002Fmodels\u002F:\u002Froot\u002F.u2net` to store model files outside the container, avoiding re-downloads.\n\n## Models\n\nAll models are automatically downloaded and saved to `~\u002F.u2net\u002F` on first use.\n\n### Available Models\n\n- u2net ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fu2net.onnx), [source](https:\u002F\u002Fgithub.com\u002Fxuebinqin\u002FU-2-Net)): A pre-trained model for general use cases.\n- u2netp ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fu2netp.onnx), [source](https:\u002F\u002Fgithub.com\u002Fxuebinqin\u002FU-2-Net)): A lightweight version of u2net model.\n- u2net_human_seg ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fu2net_human_seg.onnx), [source](https:\u002F\u002Fgithub.com\u002Fxuebinqin\u002FU-2-Net)): A pre-trained model for human segmentation.\n- u2net_cloth_seg ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fu2net_cloth_seg.onnx), [source](https:\u002F\u002Fgithub.com\u002Flevindabhi\u002Fcloth-segmentation)): A pre-trained model for Cloths Parsing from human portrait. Here clothes are parsed into 3 category: Upper body, Lower body and Full body.\n- silueta ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fsilueta.onnx), [source](https:\u002F\u002Fgithub.com\u002Fxuebinqin\u002FU-2-Net\u002Fissues\u002F295)): Same as u2net but the size is reduced to 43Mb.\n- isnet-general-use ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fisnet-general-use.onnx), [source](https:\u002F\u002Fgithub.com\u002Fxuebinqin\u002FDIS)): A new pre-trained model for general use cases.\n- isnet-anime ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fisnet-anime.onnx), [source](https:\u002F\u002Fgithub.com\u002FSkyTNT\u002Fanime-segmentation)): A high-accuracy segmentation for anime character.\n- sam ([download encoder](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fvit_b-encoder-quant.onnx), [download decoder](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fvit_b-decoder-quant.onnx), [source](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything)): A pre-trained model for any use cases.\n- birefnet-general ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-general-epoch_244.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A pre-trained model for general use cases.\n- birefnet-general-lite ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-general-bb_swin_v1_tiny-epoch_232.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A light pre-trained model for general use cases.\n- birefnet-portrait ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-portrait-epoch_150.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A pre-trained model for human portraits.\n- birefnet-dis ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-DIS-epoch_590.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A pre-trained model for dichotomous image segmentation (DIS).\n- birefnet-hrsod ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-HRSOD_DHU-epoch_115.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A pre-trained model for high-resolution salient object detection (HRSOD).\n- birefnet-cod ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-COD-epoch_125.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A pre-trained model for concealed object detection (COD).\n- birefnet-massive ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002FBiRefNet-massive-TR_DIS5K_TR_TEs-epoch_420.onnx), [source](https:\u002F\u002Fgithub.com\u002FZhengPeng7\u002FBiRefNet)): A pre-trained model with massive dataset.\n- bria-rmbg ([download](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg\u002Freleases\u002Fdownload\u002Fv0.0.0\u002Fbria-rmbg-2.0.onnx), [source](https:\u002F\u002Fhuggingface.co\u002Fbriaai\u002FRMBG-2.0)): A state-of-the-art background removal model by BRIA AI.\n\n## Environment Variables\n\n| Variable | Description |\n|----------|-------------|\n| `U2NET_HOME` | Path to the directory where models are stored. Defaults to `$XDG_DATA_HOME\u002F.u2net` (or `~\u002F.u2net` if `XDG_DATA_HOME` is not set). |\n| `XDG_DATA_HOME` | Base data directory used when `U2NET_HOME` is not set. Defaults to `~`. |\n| `MODEL_CHECKSUM_DISABLED` | When set (e.g. `MODEL_CHECKSUM_DISABLED=1`), disables hash verification for downloaded models. This is useful if you want to use your own custom\u002Fconverted model files without rembg re-downloading the originals. |\n| `OMP_NUM_THREADS` | Sets the number of threads used by ONNX Runtime for inference. |\n\n### Using custom model files\n\nIf you need to use a modified version of a model (e.g. converted to a different ONNX IR version for compatibility with an older CUDA toolkit), you can prevent rembg from overwriting it:\n\n1. Set `MODEL_CHECKSUM_DISABLED=1`\n2. Place your custom `.onnx` file in the models directory (`~\u002F.u2net\u002F` by default) with the expected filename (e.g. `u2net.onnx`)\n3. Rembg will detect the file exists and use it without re-downloading\n\n## FAQ\n\n### When will this library support Python version 3.xx?\n\nThis library depends on [onnxruntime](https:\u002F\u002Fpypi.org\u002Fproject\u002Fonnxruntime). Python version support is determined by onnxruntime's compatibility.\n\n## Support\n\nIf you find this project useful, consider buying me a coffee (or a beer):\n\n\u003Ca href=\"https:\u002F\u002Fwww.buymeacoffee.com\u002Fdanielgatis\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fbmc-cdn.nyc3.digitaloceanspaces.com\u002FBMC-button-images\u002Fcustom_images\u002Forange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\">\u003C\u002Fa>\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=danielgatis\u002Frembg&type=Date)](https:\u002F\u002Fstar-history.com\u002F#danielgatis\u002Frembg&Date)\n\n## License\n\nCopyright (c) 2020-present [Daniel Gatis](https:\u002F\u002Fgithub.com\u002Fdanielgatis)\n\nLicensed under the [MIT License](.\u002FLICENSE.txt).\n","Rembg 是一个用于移除图像背景的工具。它支持作为命令行界面、Python 库、HTTP 服务器或 Docker 容器使用，利用先进的图像处理技术实现精准的背景去除效果。项目基于 Python 开发，提供 CPU 和 GPU（NVIDIA\u002FCUDA）两种后端支持选项，以适应不同硬件环境下的性能需求。适用于需要快速准确地从图片中分离主体的各种场景，如电子商务产品展示、个人照片编辑等。MIT 许可证下开源，拥有活跃的社区支持和广泛的应用案例。",2,"2026-06-11 02:49:36","top_language"]