Видаляє фон за об’єктом. Використовує навчені моделі (посилання є на GitHub)
Встановлювати в вірт.середоище. Ставить близько 700 Мб модулів.
attrs
certifi
charset-normalizer
coloredlogs
flatbuffers
humanfriendly
idna
imageio
jsonschema
jsonschema-specifications
lazy_loader
llvmlite
mpmath
networkx
numba
numpy
onnxruntime
opencv-python-headless
packaging
pillow
platformdirs
pooch
protobuf
pymatting
referencing
requests
rpds-py
scikit-image
scipy
sympy
tifffile
tqdm
urllib3
#!/home/user/dev/rembg/env/bin/python
from rembg import remove
input_path = '/home/user/dev/rembg/test.jpg'
output_path = '/home/user/dev/rembg/test_output.png'
with open(input_path, 'rb') as i:
with open(output_path, 'wb') as o:
input = i.read()
output = remove(input)
o.write(output)
В цю директорію можно скопіювати й інші моделі.
pip install click
pip install filetype
pip install watchdog
pip install aiohttp
> multidict, frozenlist, async-timeout, yarl, aiosignal, aiohttp
pip install gradio
> aiofiles, altair, annotated-types, anyio, contourpy, cycler, exceptiongroup,
fastapi, ffmpy, filelock, fonttools, fsspec, gradio-client, h11, httpcore, httpx,
huggingface-hub, importlib-resources, jinja2, kiwisolver, markdown-it-py,
markupsafe, matplotlib, mdurl, orjson, pandas, pydantic, pydantic-core, pydub,
pygments, pyparsing, python-dateutil, python-multipart, pytz, pyyaml, rich, ruff,
semantic-version, shellingham, six, sniffio, starlette, tomlkit, toolz, typer,
typing-extensions, tzdata, uvicorn, websockets
pip install asyncer
rembg i -m MODEL ~/img/test.jpg ~/img/test_output.pngg
де MODEL - необхідний файл моделі.
rembg i -a -m MODEL ~/img/test.jpg ~/img/test_output.png