1 Star 0 Fork 1

onehand/sd-webui-roop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install.py 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
Somdev Sangwan 提交于 2023-06-19 03:54 . fixed installer
import launch
import os
import pkg_resources
import sys
from tqdm import tqdm
import urllib.request
req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
models_dir = os.path.abspath("models/roop")
model_url = "https://huggingface.co/henryruhs/roop/resolve/main/inswapper_128.onnx"
model_name = os.path.basename(model_url)
model_path = os.path.join(models_dir, model_name)
def download(url, path):
request = urllib.request.urlopen(url)
total = int(request.headers.get('Content-Length', 0))
with tqdm(total=total, desc='Downloading', unit='B', unit_scale=True, unit_divisor=1024) as progress:
urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
if not os.path.exists(models_dir):
os.makedirs(models_dir)
if not os.path.exists(model_path):
download(model_url, model_path)
print("Checking roop requirements")
with open(req_file) as file:
for package in file:
try:
python = sys.executable
package = package.strip()
if not launch.is_installed(package):
print(f"Install {package}")
launch.run_pip(
f"install {package}", f"sd-webui-roop requirement: {package}"
)
elif "==" in package:
package_name, package_version = package.split("==")
installed_version = pkg_resources.get_distribution(package_name).version
if installed_version != package_version:
print(
f"Install {package}, {installed_version} vs {package_version}"
)
launch.run_pip(
f"install {package}",
f"sd-webui-roop requirement: changing {package_name} version from {installed_version} to {package_version}",
)
except Exception as e:
print(e)
print(f"Warning: Failed to install {package}, roop will not work.")
raise e
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/onehand/sd-webui-roop.git
git@gitee.com:onehand/sd-webui-roop.git
onehand
sd-webui-roop
sd-webui-roop
main

搜索帮助