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

news/2025/1/15 21:27:22 标签: python, 图像处理

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 替换如下:

python">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 备用代码

python">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.niftyadmin.cn/n/5824349.html

相关文章

Web前端------HTML块级和行内标签之行内标签

一.行内标签介绍 行内标签----span 作用&#xff1a; 1.作为文本字体的容器&#xff0c;用来结合CSS修饰文本样式 2.根据行内标签的特性&#xff08;不换行/部分块级样式不生效eg&#xff1a;宽高等等&#xff09;&#xff0c; 做微小布局 二.代码展示 <!DOCTYPE html>…

如何调整 Nginx 工作进程数以提升性能

&#x1f3e1;作者主页&#xff1a;点击&#xff01; Nginx-从零开始的服务器之旅专栏&#xff1a;点击&#xff01; &#x1f427;Linux高级管理防护和群集专栏&#xff1a;点击&#xff01; ⏰️创作时间&#xff1a;2025年1月13日12点14分 Nginx 的工作进程数&#xff0…

信创改造-龙蜥操作系统搭载MySql、Tomcat等服务

龙蜥操作系统 Anolis OS 8 是 OpenAnolis 社区推出的完全开源、中立、开放的发行版&#xff0c;它支持多计算架构&#xff0c;也面向云端场景优化&#xff0c;兼容 CentOS 软件生态。Anolis OS 8 旨在为广大开发者和运维人员提供稳定、高性能、安全、可靠、开源的操作系统服务。…

在 Visual Studio Code 中使用 qmake 构建和调试 Qt 项目

在 Visual Studio Code 中使用 qmake 构建和调试 Qt 项目 在 Qt 开发中&#xff0c;qmake 是一个常用的构建工具。然而&#xff0c;Visual Studio Code&#xff08;VSCode&#xff09;并未直接支持 qmake&#xff0c;因此我们需要通过配置任务和调试设置来集成 qmake 项目。本…

MVC组织架构的Eclipse JavaWeb项目结构

1、MVC架构示意图 数据在MVC架构中的流动要遵循“分层逐级调用&#xff0c;禁止跨级或反向调用”的原则。 #mermaid-svg-pY0Ksr1GMHidwnXW {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-pY0Ksr1GMHidwnXW .error-…

【make】makefile 函数全解

目录 makefile简介函数全解介绍相关链接字符串处理函数subst 函数—字符串替换patsubst 函数 — 模式字符串替换strip 函数 — 去空格findstring 函数 — 查找字符串filter 函数 — 过滤器filter-out 函数 — 过滤器sort 函数 — 排序word 函数 — 取单词wordlist函数 — 取一串…

C语言 操作符练习2

1.字母大小写转换 描述&#xff1a; KiKi想完成字母大小写的转换&#xff0c;有一个字符&#xff0c;判断它是否是大写字母&#xff0c;如果是&#xff0c;将它转换成小写字母&#xff0c;反之则转换成大写字母。 输入描述&#xff1a; 多组输入&#xff0c;每一行输入一个…

AF3 BaseTriangleMultiplicativeUpdate类解读

BaseTriangleMultiplicativeUpdate 类是一个抽象基类 (ABC)&#xff0c;用于实现 AlphaFold 相关算法&#xff08;具体为算法 11 和 12&#xff09;。它的主要功能是通过三角形乘法更新成对表示张量&#xff08;pairwise representation tensor&#xff09;。 源代码&#xff…