|
| 1 | + |
| 2 | +# Rembg |
| 3 | + |
| 4 | +Rembg is a tool to remove images background. That is it. |
| 5 | + |
| 6 | +<p style="display: flex;align-items: center;justify-content: center;"> |
| 7 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-1.jpg" width="100" /> |
| 8 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-1.out.png" width="100" /> |
| 9 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-2.jpg" width="100" /> |
| 10 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-2.out.png" width="100" /> |
| 11 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-3.jpg" width="100" /> |
| 12 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/car-3.out.png" width="100" /> |
| 13 | +</p> |
| 14 | + |
| 15 | +<p style="display: flex;align-items: center;justify-content: center;"> |
| 16 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-1.jpg" width="100" /> |
| 17 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-1.out.png" width="100" /> |
| 18 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-2.jpg" width="100" /> |
| 19 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-2.out.png" width="100" /> |
| 20 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-3.jpg" width="100" /> |
| 21 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/animal-3.out.png" width="100" /> |
| 22 | +</p> |
| 23 | + |
| 24 | +<p style="display: flex;align-items: center;justify-content: center;"> |
| 25 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-1.jpg" width="100" /> |
| 26 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-1.out.png" width="100" /> |
| 27 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-2.jpg" width="100" /> |
| 28 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-2.out.png" width="100" /> |
| 29 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-3.jpg" width="100" /> |
| 30 | + <img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-3.out.png" width="100" /> |
| 31 | +</p> |
| 32 | + |
| 33 | +### Installation |
| 34 | + |
| 35 | +Install it from pypi |
| 36 | + |
| 37 | +```bash |
| 38 | + pip install rembg |
| 39 | +``` |
| 40 | + |
| 41 | +### Usage as a cli |
| 42 | + |
| 43 | +Remove the backaground from a remote image |
| 44 | +```bash |
| 45 | + curl -s http://input.png | rembg > output.png |
| 46 | +``` |
| 47 | + |
| 48 | +Remove the backaground from a local file |
| 49 | +```bash |
| 50 | + rembg -o path/to/output.png paht/to/input.png |
| 51 | +``` |
| 52 | + |
| 53 | +Remove the backaground from all images in a folder |
| 54 | +```bash |
| 55 | + rembg -p path/to/inputs |
| 56 | +``` |
| 57 | + |
| 58 | +### Usage as a server |
| 59 | + |
| 60 | +Start the server |
| 61 | +```bash |
| 62 | + rembg-server |
| 63 | +``` |
| 64 | + |
| 65 | +Open your browser to |
| 66 | +``` |
| 67 | + http://localhost:5000?url=http://image.png |
| 68 | +``` |
| 69 | + |
| 70 | +### Usage as a library |
| 71 | + |
| 72 | +In `app.py` |
| 73 | + |
| 74 | +```python |
| 75 | +import sys |
| 76 | +from rembg.bg import remove |
| 77 | + |
| 78 | +sys.stdout.buffer.write(remove(sys.stdin.buffer.read())) |
| 79 | + |
| 80 | +``` |
| 81 | + |
| 82 | +Then run |
| 83 | +``` |
| 84 | + cat input.png | python app.py > out.png |
| 85 | +``` |
| 86 | + |
| 87 | +### References |
| 88 | + |
| 89 | +- https://arxiv.org/pdf/2005.09007.pdf |
| 90 | +- https://github.com/NathanUA/U-2-Net |
| 91 | + |
| 92 | +### License |
| 93 | + |
| 94 | +Copyright (c) 2020-present [Daniel Gatis](https://github.com/danielgatis) |
| 95 | + |
| 96 | +Licensed under [MIT License](./LICENSE.txt) |
0 commit comments