feat: add script for removing backgrounds

This commit is contained in:
DBras 2024-07-03 11:35:19 +02:00
parent a56becb783
commit 22ee54e5d9
5 changed files with 48 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
venv/**/**

BIN
images/input.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
images/processed.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

37
requirements.txt Normal file
View File

@ -0,0 +1,37 @@
attrs==23.2.0
certifi==2024.6.2
charset-normalizer==3.3.2
coloredlogs==15.0.1
flatbuffers==24.3.25
greenlet==3.0.3
humanfriendly==10.0
idna==3.7
imageio==2.34.2
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
lazy_loader==0.4
llvmlite==0.43.0
mpmath==1.3.0
msgpack==1.0.8
networkx==3.3
numba==0.60.0
numpy==1.26.4
onnxruntime==1.18.1
opencv-python-headless==4.10.0.84
packaging==24.1
pillow==10.4.0
platformdirs==4.2.2
pooch==1.8.2
protobuf==5.27.2
PyMatting==1.1.12
pynvim==0.5.0
referencing==0.35.1
rembg==2.0.57
requests==2.32.3
rpds-py==0.18.1
scikit-image==0.24.0
scipy==1.14.0
sympy==1.12.1
tifffile==2024.7.2
tqdm==4.66.4
urllib3==2.2.2

10
scripts/background.py Normal file
View File

@ -0,0 +1,10 @@
from rembg import remove
in_file = '../images/input.jpg'
out_file = '../images/processed.jpg'
with open(in_file, 'rb') as i:
with open(out_file, 'wb') as o:
in_b = i.read()
out = remove(in_b)
o.write(out)