mirror of
https://git.mirrors.martin98.com/https://github.com/danielgatis/rembg
synced 2025-08-15 20:35:56 +08:00
Update README.md
This commit is contained in:
parent
308ac8b169
commit
db8f87a51a
35
README.md
35
README.md
@ -84,20 +84,35 @@ Also you can send the file as a FormData (multipart/form-data):
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Usage as a library
|
### Usage as a library
|
||||||
|
Examples:
|
||||||
|
1. In `app.py`
|
||||||
|
|
||||||
In `app.py`
|
```python
|
||||||
|
import sys
|
||||||
|
from rembg.bg import remove
|
||||||
|
|
||||||
```python
|
sys.stdout.buffer.write(remove(sys.stdin.buffer.read()))
|
||||||
import sys
|
```
|
||||||
from rembg.bg import remove
|
|
||||||
|
|
||||||
sys.stdout.buffer.write(remove(sys.stdin.buffer.read()))
|
Then run
|
||||||
```
|
```
|
||||||
|
cat input.png | python app.py > out.png
|
||||||
|
```
|
||||||
|
|
||||||
Then run
|
2. ```python
|
||||||
```
|
from rembg.bg import remove
|
||||||
cat input.png | python app.py > out.png
|
import numpy as np
|
||||||
```
|
import io
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
input_path = 'input.png'
|
||||||
|
output_path = 'out.png'
|
||||||
|
|
||||||
|
f = np.fromfile(input_path)
|
||||||
|
result = remove(f)
|
||||||
|
img = Image.open(io.BytesIO(result)).convert("RGBA")
|
||||||
|
img.save(output_path)
|
||||||
|
```
|
||||||
|
|
||||||
### Usage as a docker
|
### Usage as a docker
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user