当前位置: 首页 > article >正文

当comfyui-reactor-node 安装失败urllib.error.HTTPError: HTTP Error 403: Forbidden解决方法

comfyUI 节点comfyui-reactor-node 安装 python install 时

报错

urllib.error.HTTPError: HTTP Error 403: Forbidden 如下:

(xxx) xxxx@xxx:~/sdb/Q/ComfyUI/custom_nodes/comfyui-reactor-node$ python install.py
Traceback (most recent call last):
  File "/home/ruiy/sdb/Q/ComfyUI/custom_nodes/comfyui-reactor-node/install.py", line 62, in <module>
    download(model_url, model_path, model_name)
  File "/home/ruiy/sdb/Q/ComfyUI/custom_nodes/comfyui-reactor-node/install.py", line 53, in download
    request = urllib.request.urlopen(url)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/home/ruiy/anaconda3/envs/env/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

原因:

 墙

 墙

 墙

 墙

 墙

 墙 

 墙 

 墙 

 墙

解决方法:

修改comfyui-reactor-node中 install.py 文件中的model_url 

 将文件中的model_url 替换如下:

model_url = "https://hf-mirror.com/datasets/Gourieff/ReActor/blob/main/models/inswapper_128.onnx"

model_name = os.path.basename(model_url)
models_dir_path = os.path.join(models_dir, "insightface")
model_path = os.path.join(models_dir_path, model_name)

install.py 备用代码

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

import subprocess
import os, sys
try:
    from pkg_resources import get_distribution as distributions
except:
    from importlib_metadata import distributions
from tqdm import tqdm
import urllib.request
from packaging import version as pv
try:
    from folder_paths import models_dir
except:
    from pathlib import Path
    models_dir = os.path.join(Path(__file__).parents[2], "models")

sys.path.append(os.path.dirname(os.path.realpath(__file__)))

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

model_url = "https://hf-mirror.com/datasets/Gourieff/ReActor/blob/main/models/inswapper_128.onnx"
model_name = os.path.basename(model_url)
models_dir_path = os.path.join(models_dir, "insightface")
model_path = os.path.join(models_dir_path, model_name)

def run_pip(*args):
    subprocess.run([sys.executable, "-m", "pip", "install", "--no-warn-script-location", *args])

def is_installed (
        package: str, version: str = None, strict: bool = True
):
    has_package = None
    try:
        has_package = distributions(package)
        if has_package is not None:
            if version is not None:
                installed_version = has_package.version
                if (installed_version != version and strict == True) or (pv.parse(installed_version) < pv.parse(version) and strict == False):
                    return False
                else:
                    return True
            else:
                return True
        else:
            return False
    except Exception as e:
        print(f"Status: {e}")
        return False
    
def download(url, path, name):
    request = urllib.request.urlopen(url)
    total = int(request.headers.get('Content-Length', 0))
    with tqdm(total=total, desc=f'[ReActor] Downloading {name} to {path}', 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_path):
    os.makedirs(models_dir_path)

if not os.path.exists(model_path):
    download(model_url, model_path, model_name)

with open(req_file) as file:
    try:
        ort = "onnxruntime-gpu"
        import torch
        cuda_version = None
        if torch.cuda.is_available():
            cuda_version = torch.version.cuda
            print(f"CUDA {cuda_version}")
        elif torch.backends.mps.is_available() or hasattr(torch,'dml') or hasattr(torch,'privateuseone'):
            ort = "onnxruntime"
        if cuda_version is not None and float(cuda_version)>=12 and torch.torch_version.__version__ <= "2.2.0": # CU12.x and torch<=2.2.0
            print(f"Torch: {torch.torch_version.__version__}")
            if not is_installed(ort,"1.17.0",False):
                run_pip(ort,"--extra-index-url", "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/")
        elif cuda_version is not None and float(cuda_version)>=12 and torch.torch_version.__version__ >= "2.4.0" : # CU12.x and latest torch
            print(f"Torch: {torch.torch_version.__version__}")
            if not is_installed(ort,"1.20.1",False): # latest ort-gpu
                run_pip(ort,"-U")
        elif not is_installed(ort,"1.16.1",False):
            run_pip(ort, "-U")
    except Exception as e:
        print(e)
        print(f"Warning: Failed to install {ort}, ReActor will not work.")
        raise e
    strict = True
    for package in file:
        package_version = None
        try:
            package = package.strip()
            if "==" in package:
                package_version = package.split('==')[1]
            elif ">=" in package:
                package_version = package.split('>=')[1]
                strict = False
            if not is_installed(package,package_version,strict):
                run_pip(package)
        except Exception as e:
            print(e)
            print(f"Warning: Failed to install {package}, ReActor will not work.")
            raise e
print("Ok")


 


http://www.kler.cn/a/503355.html

相关文章:

  • Postgres对外提供服务流程
  • ubuntu22.4 ROS2 安装gazebo(环境变量配置)
  • 解决win11的vmvare和docker冲突
  • 利用Java爬虫获取淘宝商品描述item_get_descAPI接口
  • 【数据结构】第1天之Java中的数据结构
  • seo泛目录(seo泛目录程序)
  • 空指针:HttpSession异常,SpringBoot集成WebSocket
  • tmux 中鼠标滚动异常:^[[A和^[[B是什么以及如何解决
  • 51c~Pytorch~合集4
  • 【按钮防抖】el-button和普通按钮防抖,点击一次禁用一秒再恢复
  • 9分布式微服务架构
  • Windows安装HDC工具及鸿蒙手机开启HDC调试
  • Java开发关键步骤:Windows与macOS系统环境变量详细配置指南
  • 一种ESP8266+OLED时间天气显示
  • 前端进程和线程及介绍
  • 初阶数据结构【双链表及其接口的实现】
  • 安装MySQL在Linux环境下
  • 深入解析Alertmanager启动命令行参数及其作用
  • zookeeper-配置
  • [Git] 深入理解 Git 的客户端与服务器角色
  • 通信网络安全分层及关键技术解决
  • 深圳观澜森林公园及五指耙森林公园边坡自动化监测
  • C# HslCommunication库
  • java 组合框
  • Flutter(Dart)的集合类型List、Set 和 Map
  • open3d+opencv实现矩形框裁剪点云操作(C++)