Rembg is a tool to remove images background
async
Daniel Gatisc4ec5ed09f3d
diff --git a/README.md b/README.mdindex 99cf851..2e4d2ca 100644--- a/README.md+++ b/README.md@@ -34,8 +34,7 @@ Rembg is a tool to remove images background. That is it.<img src="https://raw.githubusercontent.com/danielgatis/rembg/master/examples/girl-3.out.png" width="100" /></p>-#### *** If you want to remove background from videos try this this fork: https://github.com/ecsplendid/rembg-greenscreen ***-+**If this project has helped you in any way, please consider making a [donation](https://www.buymeacoffee.com/danielgatis).**### Installation@@ -167,6 +166,10 @@ curl -s http://input.png | rembg i -a -ae 15 > output.png</tbody></table>+### In the cloud++Please contact me at [email protected] if you need help to put it on the cloud.+### References- https://arxiv.org/pdf/2005.09007.pdfdiff --git a/rembg/cli.py b/rembg/cli.pyindex e666631..40c82e1 100644--- a/rembg/cli.py+++ b/rembg/cli.py@@ -3,11 +3,13 @@ import sysfrom enum import Enumfrom typing import IO, Optional+import aiohttpimport clickimport filetypeimport onnxruntime as ortimport requestsimport uvicorn+from asyncer import asyncifyfrom fastapi import Depends, FastAPI, File, Queryfrom starlette.responses import Responsefrom tqdm import tqdm@@ -270,12 +272,17 @@ def s(port: int, log_level: str):)@app.get("/")- def get_index(url: str, commons: CommonQueryParams = Depends()):- return im_without_bg(requests.get(url).content, commons)+ async def get_index(url: str, commons: CommonQueryParams = Depends()):+ async with aiohttp.ClientSession() as session:+ async with session.get(url) as response:+ file = await response.read()+ return await asyncify(im_without_bg)(file, commons)@app.post("/")- def post_index(file: bytes = File(...), commons: CommonQueryParams = Depends()):- return im_without_bg(file, commons)+ async def post_index(+ file: bytes = File(...), commons: CommonQueryParams = Depends()+ ):+ return await asyncify(im_without_bg)(file, commons)uvicorn.run(app, host="0.0.0.0", port=port, log_level=log_level)diff --git a/requirements.txt b/requirements.txtindex 96c4728..be9af40 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,3 +1,6 @@+aiohttp==3.8.1+asyncer==0.0.1+click==8.0.3fastapi==0.72.0filetype==1.0.9gdown==4.2.0@@ -5,9 +8,7 @@ numpy==1.22.1pillow==9.0.0pymatting==1.1.5python-multipart==0.0.5-requests==2.27.1scikit-image==0.19.1scipy==1.7.3tqdm==4.62.3uvicorn==0.17.0-click==8.0.3