mirror of
https://git.mirrors.martin98.com/https://github.com/danielgatis/rembg
synced 2025-07-31 04:01:59 +08:00
fix build
This commit is contained in:
parent
0fd9774d53
commit
fe0823e513
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1,2 +1 @@
|
|||||||
src/_version.py export-subst
|
rembg/_version.py export-subst
|
||||||
src/rembg/_version.py export-subst
|
|
||||||
|
8
.github/workflows/lint_python.yml
vendored
8
.github/workflows/lint_python.yml
vendored
@ -10,8 +10,8 @@ jobs:
|
|||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
- run: pip install --upgrade pip wheel
|
- run: pip install --upgrade pip wheel
|
||||||
- run: pip install bandit black flake8 flake8-bugbear flake8-comprehensions isort safety
|
- run: pip install bandit black flake8 flake8-bugbear flake8-comprehensions isort safety
|
||||||
- run: bandit --recursive --skip B101,B104,B310,B311,B303 --exclude ./src/_version.py ./src
|
- run: bandit --recursive --skip B101,B104,B310,B311,B303 --exclude ./rembg/_version.py ./rembg
|
||||||
- run: black --force-exclude src/_version.py --check --diff ./src
|
- run: black --force-exclude src/_version.py --check --diff ./rembg
|
||||||
- run: flake8 ./src --count --ignore=E203,E266,E731,F401,F811,F841,W503 --max-complexity=15 --max-line-length=120 --show-source --statistics --exclude ./src/_version.py
|
- run: flake8 ./rembg --count --ignore=E203,E266,E731,F401,F811,F841,W503 --max-complexity=15 --max-line-length=120 --show-source --statistics --exclude ./rembg/_version.py
|
||||||
- run: isort --check-only --profile black ./src
|
- run: isort --check-only --profile black ./rembg
|
||||||
- run: safety check
|
- run: safety check
|
||||||
|
17
MANIFEST.in
17
MANIFEST.in
@ -1,15 +1,8 @@
|
|||||||
|
include MANIFEST.in
|
||||||
|
include LICENSE.txt
|
||||||
|
include README.md
|
||||||
|
include setup.py
|
||||||
include pyproject.toml
|
include pyproject.toml
|
||||||
|
|
||||||
# Include the README
|
|
||||||
include *.md
|
|
||||||
|
|
||||||
# Include the license file
|
|
||||||
include LICENSE.txt
|
|
||||||
|
|
||||||
# Include the data files
|
|
||||||
recursive-include data *
|
|
||||||
|
|
||||||
include requirements.txt
|
|
||||||
include versioneer.py
|
include versioneer.py
|
||||||
include src/_version.py
|
include rembg/_version.py
|
||||||
include src/rembg/_version.py
|
|
||||||
|
@ -6,7 +6,8 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[versioneer]
|
[versioneer]
|
||||||
VCS = "git"
|
VCS = "git"
|
||||||
style = "default"
|
style = "pep440"
|
||||||
versionfile_source = "src/rembg/_version.py"
|
versionfile_source = "rembg/_version.py"
|
||||||
versionfile_build = "_version.py"
|
versionfile_build = "rembg/_version.py"
|
||||||
tag_prefix = ""
|
tag_prefix = "v"
|
||||||
|
parentdir_prefix = "rembg-"
|
||||||
|
@ -41,10 +41,10 @@ def get_config():
|
|||||||
# _version.py
|
# _version.py
|
||||||
cfg = VersioneerConfig()
|
cfg = VersioneerConfig()
|
||||||
cfg.VCS = "git"
|
cfg.VCS = "git"
|
||||||
cfg.style = "default"
|
cfg.style = "pep440"
|
||||||
cfg.tag_prefix = ""
|
cfg.tag_prefix = "v"
|
||||||
cfg.parentdir_prefix = "None"
|
cfg.parentdir_prefix = "rembg-"
|
||||||
cfg.versionfile_source = "src/rembg/_version.py"
|
cfg.versionfile_source = "rembg/_version.py"
|
||||||
cfg.verbose = False
|
cfg.verbose = False
|
||||||
return cfg
|
return cfg
|
||||||
|
|
@ -91,19 +91,20 @@ def resize_image(img, width, height):
|
|||||||
|
|
||||||
def remove(
|
def remove(
|
||||||
data,
|
data,
|
||||||
width,
|
|
||||||
height,
|
|
||||||
model_name="u2net",
|
model_name="u2net",
|
||||||
alpha_matting=False,
|
alpha_matting=False,
|
||||||
alpha_matting_foreground_threshold=240,
|
alpha_matting_foreground_threshold=240,
|
||||||
alpha_matting_background_threshold=10,
|
alpha_matting_background_threshold=10,
|
||||||
alpha_matting_erode_structure_size=10,
|
alpha_matting_erode_structure_size=10,
|
||||||
alpha_matting_base_size=1000,
|
alpha_matting_base_size=1000,
|
||||||
|
width=None,
|
||||||
|
height=None,
|
||||||
):
|
):
|
||||||
model = get_model(model_name)
|
|
||||||
img = Image.open(io.BytesIO(data)).convert("RGB")
|
img = Image.open(io.BytesIO(data)).convert("RGB")
|
||||||
if width is not None or height is not None:
|
if width is not None or height is not None:
|
||||||
img = resize_image(img, width, height)
|
img = resize_image(img, width, height)
|
||||||
|
|
||||||
|
model = get_model(model_name)
|
||||||
mask = detect.predict(model, np.array(img)).convert("L")
|
mask = detect.predict(model, np.array(img)).convert("L")
|
||||||
|
|
||||||
if alpha_matting:
|
if alpha_matting:
|
@ -67,8 +67,8 @@ def index():
|
|||||||
BytesIO(
|
BytesIO(
|
||||||
remove(
|
remove(
|
||||||
file_content,
|
file_content,
|
||||||
width,
|
width=width,
|
||||||
height,
|
height=height,
|
||||||
model_name=model,
|
model_name=model,
|
||||||
alpha_matting=alpha_matting,
|
alpha_matting=alpha_matting,
|
||||||
alpha_matting_foreground_threshold=af,
|
alpha_matting_foreground_threshold=af,
|
@ -1,7 +1,7 @@
|
|||||||
flask==1.1.2
|
flask==1.1.2
|
||||||
numpy==1.19.5
|
numpy==1.22.0
|
||||||
pillow==8.0.1
|
pillow==8.1.2
|
||||||
scikit-image==0.17.2
|
scikit-image==0.19.1
|
||||||
torch==1.9.1
|
torch==1.9.1
|
||||||
torchvision==0.10.1
|
torchvision==0.10.1
|
||||||
waitress==1.4.4
|
waitress==1.4.4
|
||||||
|
@ -9,7 +9,8 @@ license_files = LICENSE.txt
|
|||||||
|
|
||||||
[versioneer]
|
[versioneer]
|
||||||
VCS = git
|
VCS = git
|
||||||
style = default
|
style = pep440
|
||||||
versionfile_source = src/rembg/_version.py
|
versionfile_source = rembg/_version.py
|
||||||
versionfile_build = _version.py
|
versionfile_build = rembg/_version.py
|
||||||
tag_prefix =
|
tag_prefix = v
|
||||||
|
parentdir_prefix = rembg-
|
||||||
|
7
setup.py
7
setup.py
@ -1,4 +1,8 @@
|
|||||||
import pathlib
|
import pathlib
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.append(os.path.dirname(__file__))
|
||||||
import versioneer
|
import versioneer
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
@ -23,8 +27,7 @@ setup(
|
|||||||
"Programming Language :: Python :: 3 :: Only",
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
],
|
],
|
||||||
keywords="remove, background, u2net",
|
keywords="remove, background, u2net",
|
||||||
package_dir={"": "src"},
|
packages=find_packages(include=["rembg"]),
|
||||||
packages=find_packages(where="src"),
|
|
||||||
python_requires=">=3.8, <4",
|
python_requires=">=3.8, <4",
|
||||||
install_requires=requireds,
|
install_requires=requireds,
|
||||||
entry_points={
|
entry_points={
|
||||||
|
Loading…
x
Reference in New Issue
Block a user