mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-04-27 17:51:31 +00:00
fix: protobuf version, misc
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = "23.5.2.post0"
|
||||
__version__ = "23.5.2.post1"
|
||||
|
||||
@@ -10,6 +10,8 @@ import numpy as np
|
||||
from huggingface_hub import hf_hub_download
|
||||
from PIL import Image, ImageChops, ImageDraw
|
||||
|
||||
repo_id = "Bingsu/adetailer"
|
||||
|
||||
|
||||
@dataclass
|
||||
class PredictOutput:
|
||||
@@ -20,17 +22,22 @@ class PredictOutput:
|
||||
|
||||
def get_models(model_dir: str | Path) -> OrderedDict[str, str | None]:
|
||||
model_dir = Path(model_dir)
|
||||
model_paths = [
|
||||
p for p in model_dir.rglob("*") if p.is_file() and p.suffix in (".pt", ".pth")
|
||||
]
|
||||
if model_dir.is_dir():
|
||||
model_paths = [
|
||||
p
|
||||
for p in model_dir.rglob("*")
|
||||
if p.is_file() and p.suffix in (".pt", ".pth")
|
||||
]
|
||||
else:
|
||||
model_paths = []
|
||||
|
||||
models = OrderedDict(
|
||||
{
|
||||
"face_yolov8n.pt": hf_hub_download("Bingsu/adetailer", "face_yolov8n.pt"),
|
||||
"face_yolov8s.pt": hf_hub_download("Bingsu/adetailer", "face_yolov8s.pt"),
|
||||
"face_yolov8n.pt": hf_hub_download(repo_id, "face_yolov8n.pt"),
|
||||
"face_yolov8s.pt": hf_hub_download(repo_id, "face_yolov8s.pt"),
|
||||
"mediapipe_face_full": None,
|
||||
"mediapipe_face_short": None,
|
||||
"hand_yolov8n.pt": hf_hub_download("Bingsu/adetailer", "hand_yolov8n.pt"),
|
||||
"hand_yolov8n.pt": hf_hub_download(repo_id, "hand_yolov8n.pt"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ if ext_path.exists():
|
||||
|
||||
if not controlnet_exists and ext_builtin_path.exists():
|
||||
controlnet_exists = any(
|
||||
p.name == "sd-webui-controlnet" for p in ext_builtin_path.iterdir()
|
||||
p.name == "sd-webui-controlnet"
|
||||
for p in ext_builtin_path.iterdir()
|
||||
if p.is_dir()
|
||||
)
|
||||
|
||||
if controlnet_exists:
|
||||
|
||||
38
install.py
38
install.py
@@ -8,7 +8,9 @@ from importlib.metadata import version # python >= 3.8
|
||||
from packaging.version import parse
|
||||
|
||||
|
||||
def is_installed(package: str, min_version: str | None = None):
|
||||
def is_installed(
|
||||
package: str, min_version: str | None = None, max_version: str | None = None
|
||||
):
|
||||
try:
|
||||
spec = importlib.util.find_spec(package)
|
||||
except ModuleNotFoundError:
|
||||
@@ -17,11 +19,17 @@ def is_installed(package: str, min_version: str | None = None):
|
||||
if spec is None:
|
||||
return False
|
||||
|
||||
if not min_version:
|
||||
if not min_version and not max_version:
|
||||
return True
|
||||
|
||||
pkg_version = version(package)
|
||||
if not min_version:
|
||||
min_version = "0.0.0"
|
||||
if not max_version:
|
||||
max_version = "99999999.99999999.99999999"
|
||||
|
||||
try:
|
||||
return parse(version(package)) >= parse(min_version)
|
||||
return parse(min_version) <= parse(pkg_version) <= parse(max_version)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -32,14 +40,26 @@ def run_pip(*args):
|
||||
|
||||
def install():
|
||||
deps = [
|
||||
("ultralytics", "8.0.87"),
|
||||
("mediapipe", "0.9.3.0"),
|
||||
("huggingface_hub", None),
|
||||
# requirements
|
||||
("ultralytics", "8.0.87", None),
|
||||
("mediapipe", "0.9.3.0", None),
|
||||
("huggingface_hub", None, None),
|
||||
# mediapipe
|
||||
("protobuf", "3.20.0", "3.20.9999"),
|
||||
]
|
||||
|
||||
for name, ver in deps:
|
||||
if not is_installed(name, ver):
|
||||
run_pip("-U", name, "--prefer-binary")
|
||||
for name, low, high in deps:
|
||||
if not is_installed(name, low, high):
|
||||
if low and high:
|
||||
cmd = f"{name}>={low},<={high}"
|
||||
elif low:
|
||||
cmd = f"{name}>={low}"
|
||||
elif high:
|
||||
cmd = f"{name}<={high}"
|
||||
else:
|
||||
cmd = name
|
||||
|
||||
run_pip("-U", cmd)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -87,7 +87,7 @@ class ADetailerArgs:
|
||||
try:
|
||||
args[i] = dtype(args[i])
|
||||
except ValueError as e:
|
||||
msg = f"Error converting {attr!r} to {dtype}: {e}"
|
||||
msg = f"Error converting {args[i]!r}({attr}) to {dtype}: {e}"
|
||||
raise ValueError(msg) from e
|
||||
return args
|
||||
|
||||
|
||||
Reference in New Issue
Block a user