AI大模型学习三十、ubuntu安装comfyui,安装插件,修改返回405 bug,值得一看喔

一、说明

ComfyUI是一个开源的、基于节点的Web应用。它允许用户根据一系列文本提示(Prompt)生成图像。

ComfyUI使用扩散模型作为基础模型,并结合 ControlNet、Lora和LCM低阶自适应等模型,每个工具都由程序中的一个节点表示

二、开发环境搭建

1、创建云环境

2、下载源码

复制代码
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfuUI

#重要目录说明

SD权重路径默认为:models/checkpoints

VAE文件路径默认为:models/vae

插件路径默认为:custom_nodes

3、安装插件管理器ComfyUI-Manager

复制代码
cd costum_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git

4、创造虚拟环境

复制代码
conda create -n comfyui python=3.10
conda activate comfyui

# torch
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121

conda install -c conda-forge ffmpeg=6.1

pip install -r requirements.txt

5、修改 ComfyUI/app/user_manager.py 文件

发现问题主要是不能保存

复制代码
# 在最后添加,注意格式
   @routes.post("/userdata/{dir}/{file}")
        async def post_userdata_1(request):
            logging.info(f"post_userdata_1 request: {request}")
            path = get_user_data_workfolows_path(request)
            logging.info(f"post_userdata_1 path: {path}")
            if not isinstance(path, str):
                return path

            overwrite = request.query.get("overwrite", 'true') != "false"
            full_info = request.query.get('full_info', 'false').lower() == "true"

            if not overwrite and os.path.exists(path):
                return web.Response(status=409, text="File already exists")

            body = await request.read()

            with open(path, "wb") as f:
                f.write(body)

            user_path = self.get_request_user_filepath(request, None)
            if full_info:
                resp = get_file_info(path, user_path)
            else:
                resp = os.path.relpath(path, user_path)

            return web.json_response(resp)


        @routes.get("/userdata/{dir}/{file}")
        async def getuserdata_1(request):
            path = get_user_data_workfolows_path(request)
            if not isinstance(path, str):
                return path

            return web.FileResponse(path)


        @routes.delete("/userdata/{dir}/{file}")
        async def delete_userdata_1(request):
            path = get_user_data_workfolows_path(request, check_exists=True)
            if not isinstance(path, str):
                return path

            os.remove(path)

            return web.Response(status=204)

        @routes.post("/userdata/{dir}/{file}/move/{dir_}/{dest}")
        async def move_userdata_1(request):
            """
            Move or rename a user data file.
            """
            source = get_user_data_workfolows_path(request, check_exists=True)
            if not isinstance(source, str):
                return source

            dest = get_user_data_workfolows_path(request, check_exists=False, param="dest")
            if not isinstance(source, str):
                return dest

            overwrite = request.query.get("overwrite", 'true') != "false"
            full_info = request.query.get('full_info', 'false').lower() == "true"

            if not overwrite and os.path.exists(dest):
                return web.Response(status=409, text="File already exists")

            logging.info(f"moving '{source}' -> '{dest}'")
            shutil.move(source, dest)

            user_path = self.get_request_user_filepath(request, None)
            if full_info:
                resp = get_file_info(dest, user_path)
            else:
                resp = os.path.relpath(dest, user_path)

            return web.json_response(resp)

6、运行

复制代码
python main.py --listen 0.0.0.0

参数解析

--listen:是否进本地可访问
--port:服务的端口 默认8188
--preview-method auto:开启预览VAE解码前的图像

三、配置 && Debug

修改模型文件的路径

#将extra_model_paths.yaml.example重命名为extra_model_paths.yaml以启用该文件

cp extra_model_paths.yaml.example extra_model_paths.yaml

#然后修改文件中的base_paths并设置为stablediffusion-webui的项目路径。

路径为/workspace/stablediffusion-webui/

四、安装插件

第一个

第二个

相关推荐
算家计算9 分钟前
AI大神100美元手搓ChatGPT!nanochat教程爆火,4小时炼成聊天机器人
人工智能·chatgpt·资讯
Kaydeon10 分钟前
【AIGC】50倍加速!NVIDIA蒸馏算法rCM:分数正则化连续时间一致性模型的大规模扩散蒸馏
人工智能·pytorch·python·深度学习·计算机视觉·aigc
阿里云大数据AI技术24 分钟前
AI刷新赛事体验,PAI-ArtLab支撑“我的NBA AI手办”互动
人工智能
~无忧花开~34 分钟前
JavaScript学习笔记(二十八):JavaScript性能优化全攻略
开发语言·前端·javascript·笔记·学习·性能优化·js
机器学习之心35 分钟前
PINN物理信息神经网络风电功率预测!引入物理先验知识嵌入学习的风电功率预测新范式!Matlab实现
神经网络·学习·matlab·风电功率预测·物理信息神经网络
zhy2956336 分钟前
【DNN】基础环境搭建
人工智能·tensorrt·cuda·开发环境·cudnn
PKNLP38 分钟前
NLP入门
人工智能·自然语言处理
Mr.Lee jack40 分钟前
体验GPT-OSS-120B:在PH8平台上探索超大规模语言模型的强大能力
人工智能·gpt·语言模型·openai·deepseek
余衫马41 分钟前
大语言模型(LLM)领域细分方向解析
人工智能·语言模型·自然语言处理·llm·领域方向
小关会打代码43 分钟前
自然语言处理(NLP)之分词
人工智能·自然语言处理