代码拉取完成,页面将自动刷新
同步操作将从 sd-webui/adetailer 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from __future__ import annotations
import importlib.util
import subprocess
import sys
from importlib.metadata import version # python >= 3.8
from packaging.version import parse
def is_installed(
package: str, min_version: str | None = None, max_version: str | None = None
):
try:
spec = importlib.util.find_spec(package)
except ModuleNotFoundError:
return False
if spec is None:
return False
if not min_version and not max_version:
return True
if not min_version:
min_version = "0.0.0"
if not max_version:
max_version = "99999999.99999999.99999999"
if package == "google.protobuf":
package = "protobuf"
try:
pkg_version = version(package)
return parse(min_version) <= parse(pkg_version) <= parse(max_version)
except Exception:
return False
def run_pip(*args):
subprocess.run([sys.executable, "-m", "pip", "install", *args])
def install():
deps = [
# requirements
("ultralytics", "8.0.97", None),
("mediapipe", "0.10.0", None),
("huggingface_hub", None, None),
("pydantic", "1.10.8", None),
("rich", "13.4.2", None),
# mediapipe
("protobuf", "3.20.0", "3.20.9999"),
]
for pkg, low, high in deps:
# https://github.com/protocolbuffers/protobuf/tree/main/python
name = "google.protobuf" if pkg == "protobuf" else pkg
if not is_installed(name, low, high):
if low and high:
cmd = f"{pkg}>={low},<={high}"
elif low:
cmd = f"{pkg}>={low}"
elif high:
cmd = f"{pkg}<={high}"
else:
cmd = pkg
run_pip("-U", cmd)
try:
import launch
skip_install = launch.args.skip_install
except Exception:
skip_install = False
if not skip_install:
install()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。