一、說明
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/cu121conda install -c conda-forge ffmpeg=6.1pip 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 pathoverwrite = 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 pathreturn 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 pathos.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 sourcedest = get_user_data_workfolows_path(request, check_exists=False, param="dest")if not isinstance(source, str):return destoverwrite = 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/
四、安裝插件
第一個
第二個
?