mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-01-26 19:29:54 +00:00
Merge branch 'dev'
This commit is contained in:
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@@ -22,16 +22,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- uses: astral-sh/setup-uv@v5
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- uses: astral-sh/setup-uv@v3
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
uv pip install --system ".[test]"
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest -v
|
run: uv run --all-extras pytest -v
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ repos:
|
|||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
|
|
||||||
- repo: https://github.com/rbubley/mirrors-prettier
|
- repo: https://github.com/rbubley/mirrors-prettier
|
||||||
rev: v3.4.1
|
rev: v3.5.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: prettier
|
- id: prettier
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.8.1
|
rev: v0.9.9
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-03-10
|
||||||
|
|
||||||
|
- v25.3.0
|
||||||
|
- unsafe pickling 방법 변경
|
||||||
|
|
||||||
## 2024-11-13
|
## 2024-11-13
|
||||||
|
|
||||||
- v24.11.1
|
- v24.11.1
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- echo "$PYTHON"
|
- echo "$PYTHON"
|
||||||
- echo "$WEBUI"
|
- echo "$WEBUI"
|
||||||
- echo "$UV_PYTHON"
|
|
||||||
silent: true
|
silent: true
|
||||||
|
|
||||||
launch:
|
launch:
|
||||||
dir: "{{.WEBUI}}"
|
dir: "{{.WEBUI}}"
|
||||||
cmds:
|
cmds:
|
||||||
- "{{.PYTHON}} launch.py --xformers --api"
|
- "{{.PYTHON}} launch.py --xformers --api {{ .CLI_ARGS }}"
|
||||||
silent: true
|
silent: true
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@@ -29,4 +28,4 @@ tasks:
|
|||||||
|
|
||||||
update-torch:
|
update-torch:
|
||||||
cmds:
|
cmds:
|
||||||
- "{{.PYTHON}} -m uv pip install -U torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu124"
|
- "{{.PYTHON}} -m uv pip install -U torch torchvision torchaudio xformers --extra-index-url https://download.pytorch.org/whl/cu126"
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from typing import TYPE_CHECKING, Any, Union
|
from typing import TYPE_CHECKING, Any, Union
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from typing_extensions import Protocol
|
from typing_extensions import Protocol
|
||||||
|
|
||||||
from modules import safe
|
from modules import safe
|
||||||
from modules.shared import opts
|
from modules.shared import cmd_opts, opts
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
# 타입 체커가 빨간 줄을 긋지 않게 하는 편법
|
# 타입 체커가 빨간 줄을 긋지 않게 하는 편법
|
||||||
@@ -37,13 +39,18 @@ def change_torch_load():
|
|||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def pause_total_tqdm():
|
def disable_safe_unpickle():
|
||||||
orig = opts.data.get("multiple_tqdm", True)
|
with (
|
||||||
try:
|
patch.dict(os.environ, {"TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD": "1"}, clear=False),
|
||||||
opts.data["multiple_tqdm"] = False
|
patch.object(cmd_opts, "disable_safe_unpickle", True),
|
||||||
|
):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def pause_total_tqdm():
|
||||||
|
with patch.dict(opts.data, {"multiple_tqdm": False}, clear=False):
|
||||||
yield
|
yield
|
||||||
finally:
|
|
||||||
opts.data["multiple_tqdm"] = orig
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations # noqa: A005
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import platform
|
import platform
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = "24.11.1"
|
__version__ = "25.3.0"
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ def hf_download(file: str, repo_id: str = REPO_ID, check_remote: bool = True) ->
|
|||||||
with suppress(Exception):
|
with suppress(Exception):
|
||||||
return hf_hub_download(repo_id, file, local_files_only=True)
|
return hf_hub_download(repo_id, file, local_files_only=True)
|
||||||
|
|
||||||
msg = f"[-] ADetailer: Failed to load model {file!r} from huggingface"
|
if check_remote:
|
||||||
print(msg)
|
msg = f"[-] ADetailer: Failed to load model {file!r} from huggingface"
|
||||||
|
print(msg)
|
||||||
return "INVALID"
|
return "INVALID"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
install.py
16
install.py
@@ -8,10 +8,6 @@ from importlib.metadata import version # python >= 3.8
|
|||||||
from packaging.version import parse
|
from packaging.version import parse
|
||||||
|
|
||||||
import_name = {"py-cpuinfo": "cpuinfo", "protobuf": "google.protobuf"}
|
import_name = {"py-cpuinfo": "cpuinfo", "protobuf": "google.protobuf"}
|
||||||
custom_requirements = {
|
|
||||||
"ultralytics": "ultralytics>=8.3.0,!=8.3.41,!=8.3.42,!=8.3.45,!=8.3.46"
|
|
||||||
}
|
|
||||||
excluded_versions = {"ultralytics": ("8.3.41", "8.3.42", "8.3.45", "8.3.46")}
|
|
||||||
|
|
||||||
|
|
||||||
def is_installed(
|
def is_installed(
|
||||||
@@ -20,7 +16,6 @@ def is_installed(
|
|||||||
max_version: str | None = None,
|
max_version: str | None = None,
|
||||||
):
|
):
|
||||||
name = import_name.get(package, package)
|
name = import_name.get(package, package)
|
||||||
excluded = excluded_versions.get(package, ())
|
|
||||||
try:
|
try:
|
||||||
spec = importlib.util.find_spec(name)
|
spec = importlib.util.find_spec(name)
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
@@ -39,10 +34,7 @@ def is_installed(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pkg_version = version(package)
|
pkg_version = version(package)
|
||||||
return (
|
return parse(min_version) <= parse(pkg_version) <= parse(max_version)
|
||||||
parse(min_version) <= parse(pkg_version) <= parse(max_version)
|
|
||||||
and pkg_version not in excluded
|
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -54,7 +46,7 @@ def run_pip(*args):
|
|||||||
def install():
|
def install():
|
||||||
deps = [
|
deps = [
|
||||||
# requirements
|
# requirements
|
||||||
("ultralytics", "8.3.0", None),
|
("ultralytics", "8.3.75", None),
|
||||||
("mediapipe", "0.10.13", "0.10.15"),
|
("mediapipe", "0.10.13", "0.10.15"),
|
||||||
("rich", "13.0.0", None),
|
("rich", "13.0.0", None),
|
||||||
]
|
]
|
||||||
@@ -62,9 +54,7 @@ def install():
|
|||||||
pkgs = []
|
pkgs = []
|
||||||
for pkg, low, high in deps:
|
for pkg, low, high in deps:
|
||||||
if not is_installed(pkg, low, high):
|
if not is_installed(pkg, low, high):
|
||||||
if pkg in custom_requirements:
|
if low and high:
|
||||||
cmd = custom_requirements[pkg]
|
|
||||||
elif low and high:
|
|
||||||
cmd = f"{pkg}>={low},<={high}"
|
cmd = f"{pkg}>={low},<={high}"
|
||||||
elif low:
|
elif low:
|
||||||
cmd = f"{pkg}>={low}"
|
cmd = f"{pkg}>={low}"
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import modules
|
|||||||
from aaaaaa.conditional import create_binary_mask, schedulers
|
from aaaaaa.conditional import create_binary_mask, schedulers
|
||||||
from aaaaaa.helper import (
|
from aaaaaa.helper import (
|
||||||
PPImage,
|
PPImage,
|
||||||
change_torch_load,
|
|
||||||
copy_extra_params,
|
copy_extra_params,
|
||||||
|
disable_safe_unpickle,
|
||||||
pause_total_tqdm,
|
pause_total_tqdm,
|
||||||
preserve_prompts,
|
preserve_prompts,
|
||||||
)
|
)
|
||||||
@@ -825,8 +825,8 @@ class AfterDetailerScript(scripts.Script):
|
|||||||
pred = mediapipe_predict(args.ad_model, pp.image, args.ad_confidence)
|
pred = mediapipe_predict(args.ad_model, pp.image, args.ad_confidence)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
with change_torch_load():
|
ad_model = self.get_ad_model(args.ad_model)
|
||||||
ad_model = self.get_ad_model(args.ad_model)
|
with disable_safe_unpickle():
|
||||||
pred = ultralytics_predict(
|
pred = ultralytics_predict(
|
||||||
ad_model,
|
ad_model,
|
||||||
image=pp.image,
|
image=pp.image,
|
||||||
|
|||||||
Reference in New Issue
Block a user