Skip to content

Commit

Permalink
Install fix, albumentations pydantic insightface, onnxruntime-gpu (#2761
Browse files Browse the repository at this point in the history
)

* fix insightface pydantic

* pkg_resources -> importlib.metadata

* onnxruntime / onnxruntime-gpu

* albumentations==1.4.3

dependency incompatibility compatibility with albumentations==1.4.4
whitch requires
- pydantic required: >=2.6.4

webui 1.9 with gradio==3.41.2 / fastapi==0.94.0 requires
- pydantic required: >=1.7.4,<3.0.0,!=2.0.1,!=2.0.0,!=1.8.1,!=1.8

solution for now
pin albumentations==1.4.3 as control net requirement
which doesn't requires pydantic
  • Loading branch information
w-e-w committed Apr 18, 2024
1 parent 3a85645 commit f6bc98a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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

0 comments on commit f6bc98a

Please sign in to comment.