Skip to content

Commit

Permalink
🐛 Fix install.py
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Aug 4, 2023
1 parent ba86578 commit 2b17833
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
30 changes: 21 additions & 9 deletions install.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import launch
import os
import pkg_resources
import subprocess

req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")

Expand All @@ -20,18 +19,31 @@
print(e)
print(f'Warning: Failed to install {package}, some preprocessors may not work.')


# DW Pose dependencies.
def install_mim():
import importlib
module_spec = importlib.util.find_spec('mim')
if module_spec is None:
launch.run_pip("install openmim", "sd-webui-controlnet requirement: openmim")

mim_packages = [
"mmengine",
"mmcv>=2.0.1",
"mmdet>=3.1.0",
"mmpose>=1.1.0",
]
for package in mim_packages:
try:
package_name = package.split('>=')[0]
if not launch.is_installed(package_name):
subprocess.call(["mim", "install", package])
except Exception as e:
print(f'Warning: Failed to install {package}. {e}')

def install_mim_packages(packages):
import mim
for package in mim_packages:
packages = {p for (p, *_) in mim.list_package()}
try:
package_name = package.split('>=')[0]
if package_name not in packages:
mim.install([package])
except Exception as e:
print(f'Warning: Failed to install {package}. {e}')
raise e

install_mim()
install_mim_packages(mim_packages)
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mediapipe
svglib
fvcore
openmim
fvcore

0 comments on commit 2b17833

Please sign in to comment.