Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install fix, albumentations pydantic insightface, onnxruntime-gpu #2761

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import launch
import pkg_resources
from importlib import metadata
import sys
import os
import shutil
Expand All @@ -18,7 +18,7 @@ def comparable_version(version: str) -> Tuple:

def get_installed_version(package: str) -> Optional[str]:
try:
return pkg_resources.get_distribution(package).version
return metadata.version(package)
except Exception:
return None

Expand Down Expand Up @@ -63,6 +63,20 @@ def install_requirements(req_file):
)


def install_onnxruntime():
"""
Install onnxruntime or onnxruntime-gpu based on the availability of CUDA.
onnxruntime and onnxruntime-gpu can not be installed together.
"""
if not launch.is_installed("onnxruntime") and not launch.is_installed("onnxruntime-gpu"):
import torch.cuda as cuda # torch import head to improve loading time
onnxruntime = 'onnxruntime-gpu' if cuda.is_available() else 'onnxruntime'
launch.run_pip(
f'install {onnxruntime}',
f"sd-webui-controlnet requirement: {onnxruntime}",
)


def try_install_from_wheel(pkg_name: str, wheel_url: str, version: Optional[str] = None):
current_version = get_installed_version(pkg_name)
if current_version is not None:
Expand Down Expand Up @@ -133,6 +147,7 @@ def try_remove_legacy_submodule():


install_requirements(main_req_file)
install_onnxruntime()
try_install_insight_face()
try_install_from_wheel(
"handrefinerportable",
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fvcore
mediapipe
onnxruntime
opencv-python>=4.8.0
svglib
addict
yapf
yapf
albumentations==1.4.3
Loading