mirror of
https://git.mirrors.martin98.com/https://github.com/danielgatis/rembg
synced 2025-08-05 00:20:37 +08:00
Split depedencies (#471)
This commit is contained in:
parent
3cbad20f33
commit
bcb45a27ea
5
.github/workflows/lint_python.yml
vendored
5
.github/workflows/lint_python.yml
vendored
@ -10,9 +10,8 @@ jobs:
|
|||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.11
|
python-version: 3.11
|
||||||
- run: pip install --upgrade pip wheel
|
- name: Install dependencies
|
||||||
- run: pip install --upgrade setuptools
|
run: pip install .[cli,dev]
|
||||||
- run: pip install bandit black flake8 flake8-bugbear flake8-comprehensions isort safety mypy
|
|
||||||
- run: mypy --install-types --non-interactive --ignore-missing-imports ./rembg
|
- run: mypy --install-types --non-interactive --ignore-missing-imports ./rembg
|
||||||
- run: bandit --recursive --skip B101,B104,B310,B311,B303,B110 --exclude ./rembg/_version.py ./rembg
|
- run: bandit --recursive --skip B101,B104,B310,B311,B303,B110 --exclude ./rembg/_version.py ./rembg
|
||||||
- run: black --force-exclude rembg/_version.py --check --diff ./rembg
|
- run: black --force-exclude rembg/_version.py --check --diff ./rembg
|
||||||
|
8
.github/workflows/publish_pypi.yml
vendored
8
.github/workflows/publish_pypi.yml
vendored
@ -13,11 +13,9 @@ jobs:
|
|||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.11
|
python-version: 3.11
|
||||||
- name: "Installs dependencies"
|
- name: Install dependencies
|
||||||
run: |
|
run: pip install .[cli,dev]
|
||||||
python3 -m pip install --upgrade pip
|
- name: Builds and uploads to PyPI
|
||||||
python3 -m pip install setuptools wheel twine
|
|
||||||
- name: "Builds and uploads to PyPI"
|
|
||||||
run: |
|
run: |
|
||||||
python3 setup.py sdist bdist_wheel
|
python3 setup.py sdist bdist_wheel
|
||||||
python3 -m twine upload dist/*
|
python3 -m twine upload dist/*
|
||||||
|
7
.github/workflows/test-install.yml
vendored
7
.github/workflows/test-install.yml
vendored
@ -15,11 +15,8 @@ jobs:
|
|||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install package
|
- name: Install dependencies
|
||||||
run: |
|
run: pip install .[cli,dev]
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install .
|
|
||||||
pip install pytest
|
|
||||||
- name: Test installation with pytest
|
- name: Test installation with pytest
|
||||||
run: |
|
run: |
|
||||||
pytest
|
pytest
|
||||||
|
25
.github/workflows/test-specific-environment.yml
vendored
25
.github/workflows/test-specific-environment.yml
vendored
@ -1,25 +0,0 @@
|
|||||||
name: Test in specific environment
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Set up environment
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install pytest
|
|
||||||
pip install -r requirements.txt
|
|
||||||
- name: Test with pytest
|
|
||||||
run: |
|
|
||||||
PYTHONPATH=$PYTHONPATH:. pytest .
|
|
@ -80,7 +80,8 @@ python: >3.7, <3.12
|
|||||||
CPU support:
|
CPU support:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install rembg
|
pip install rembg # for library
|
||||||
|
pip install rembg[cli] # for library + cli
|
||||||
```
|
```
|
||||||
|
|
||||||
GPU support:
|
GPU support:
|
||||||
@ -96,7 +97,8 @@ Go to https://onnxruntime.ai and check the installation matrix.
|
|||||||
If yes, just run:
|
If yes, just run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install rembg[gpu]
|
pip install rembg[gpu] # for library
|
||||||
|
pip install rembg[gpu,cli] # for library + cli
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage as a cli
|
## Usage as a cli
|
||||||
|
27
rembg/cli.py
27
rembg/cli.py
@ -1,14 +1,33 @@
|
|||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
package_distribution = pkg_resources.get_distribution("rembg")
|
||||||
|
|
||||||
|
for extra in package_distribution.extras:
|
||||||
|
if extra == "cli":
|
||||||
|
requirements = package_distribution.requires(extras=(extra,))
|
||||||
|
for requirement in requirements:
|
||||||
|
try:
|
||||||
|
pkg_resources.require(requirement.project_name)
|
||||||
|
except pkg_resources.DistributionNotFound:
|
||||||
|
print(f"Missing dependency: '{requirement.project_name}'")
|
||||||
|
print(
|
||||||
|
"Please, install rembg with the cli feature: pip install rembg[cli]"
|
||||||
|
)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from . import _version
|
from . import _version
|
||||||
from .commands import command_functions
|
from .commands import command_functions
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.version_option(version=_version.get_versions()["version"])
|
@click.version_option(version=_version.get_versions()["version"])
|
||||||
def main() -> None:
|
def _main() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
for command in command_functions:
|
for command in command_functions:
|
||||||
main.add_command(command)
|
_main.add_command(command)
|
||||||
|
|
||||||
|
_main()
|
||||||
|
@ -1 +0,0 @@
|
|||||||
onnxruntime-gpu
|
|
@ -1,19 +0,0 @@
|
|||||||
aiohttp
|
|
||||||
asyncer
|
|
||||||
click
|
|
||||||
fastapi
|
|
||||||
filetype
|
|
||||||
gradio
|
|
||||||
imagehash
|
|
||||||
numpy
|
|
||||||
onnxruntime
|
|
||||||
opencv-python-headless
|
|
||||||
pillow
|
|
||||||
pooch
|
|
||||||
pymatting
|
|
||||||
python-multipart
|
|
||||||
scikit-image
|
|
||||||
scipy
|
|
||||||
tqdm
|
|
||||||
uvicorn
|
|
||||||
watchdog
|
|
80
setup.py
80
setup.py
@ -11,6 +11,52 @@ here = pathlib.Path(__file__).parent.resolve()
|
|||||||
|
|
||||||
long_description = (here / "README.md").read_text(encoding="utf-8")
|
long_description = (here / "README.md").read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
install_requires = [
|
||||||
|
"numpy",
|
||||||
|
"onnxruntime",
|
||||||
|
"opencv-python-headless",
|
||||||
|
"pillow",
|
||||||
|
"pooch",
|
||||||
|
"pymatting",
|
||||||
|
"scikit-image",
|
||||||
|
"scipy",
|
||||||
|
]
|
||||||
|
|
||||||
|
extras_require = {
|
||||||
|
"dev": [
|
||||||
|
"bandit",
|
||||||
|
"black",
|
||||||
|
"flake8",
|
||||||
|
"imagehash",
|
||||||
|
"isort",
|
||||||
|
"mypy",
|
||||||
|
"pytest",
|
||||||
|
"setuptools",
|
||||||
|
"twine",
|
||||||
|
"wheel",
|
||||||
|
],
|
||||||
|
"gpu": ["onnxruntime-gpu"],
|
||||||
|
"cli": [
|
||||||
|
"aiohttp",
|
||||||
|
"asyncer",
|
||||||
|
"click",
|
||||||
|
"fastapi",
|
||||||
|
"filetype",
|
||||||
|
"gradio",
|
||||||
|
"python-multipart",
|
||||||
|
"tqdm",
|
||||||
|
"uvicorn",
|
||||||
|
"watchdog",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
entry_points = {
|
||||||
|
"console_scripts": [
|
||||||
|
"rembg=rembg.cli:main",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="rembg",
|
name="rembg",
|
||||||
description="Remove image background",
|
description="Remove image background",
|
||||||
@ -35,37 +81,11 @@ setup(
|
|||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
],
|
],
|
||||||
keywords="remove, background, u2net",
|
keywords="remove, background, u2net",
|
||||||
packages=["rembg", "rembg.sessions", "rembg.commands"],
|
|
||||||
python_requires=">=3.8, <3.12",
|
python_requires=">=3.8, <3.12",
|
||||||
install_requires=[
|
packages=find_packages(),
|
||||||
"aiohttp",
|
install_requires=install_requires,
|
||||||
"asyncer",
|
entry_points=entry_points,
|
||||||
"click",
|
extras_require=extras_require,
|
||||||
"fastapi",
|
|
||||||
"filetype",
|
|
||||||
"gradio",
|
|
||||||
"imagehash",
|
|
||||||
"numpy",
|
|
||||||
"onnxruntime",
|
|
||||||
"opencv-python-headless",
|
|
||||||
"pillow",
|
|
||||||
"pooch",
|
|
||||||
"pymatting",
|
|
||||||
"python-multipart",
|
|
||||||
"scikit-image",
|
|
||||||
"scipy",
|
|
||||||
"tqdm",
|
|
||||||
"uvicorn",
|
|
||||||
"watchdog",
|
|
||||||
],
|
|
||||||
entry_points={
|
|
||||||
"console_scripts": [
|
|
||||||
"rembg=rembg.cli:main",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
extras_require={
|
|
||||||
"gpu": ["onnxruntime-gpu"],
|
|
||||||
},
|
|
||||||
version=versioneer.get_version(),
|
version=versioneer.get_version(),
|
||||||
cmdclass=versioneer.get_cmdclass(),
|
cmdclass=versioneer.get_cmdclass(),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user