ComfyUI 文生图之初体验
一、初始化环境
# 使用conda初始化环境
$ conda create -n comfyui_torch26_py312 python=3.12 -y
# 激活虚拟环境
$ conda activate comfyui_torch26_py312
# 安装服务器资源监控 -- 查看监控运行:nvitop
$ conda install -c conda-forge nvitop
# 安装pytorch
$ pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu118
# 安装魔塔社区
$ pip install modelscope
二、下载Ngork
因为CloudStudio的免费空间无法开放端口,所以需要内网穿透才能访问;
ngrok官网:https://dashboard.ngrok.com/
需要去官网申请accessToken才能正常使用!
# 配置内网穿透
$ apt update
$ apt install curl -y
$ curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
| tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \
&& echo "deb https://ngrok-agent.s3.amazonaws.com buster main" \
| tee /etc/apt/sources.list.d/ngrok.list \
&& apt update \
&& apt install ngrok
# Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml
$ ngrok config add-authtoken [填你自己的token,从ngork官方获取]
$ ngrok http 8188
三、下载ComfyUI
# 下载ComfyUI
$ git clone https://github.com/comfyanonymous/ComfyUI.git
# 进入ComfyUI目录
$ cd ComfyUI
# 安装依赖
$ pip install -r requirements.txt
# 启动ComfyUI -- 也可以等全部下载完再统一启动
$ python main.py
通过ngork代理出来的IP就可以在浏览器进入ComfyUI了;
如果需要汉化ComfyUI的话,看这里,否则跳过:
$ cd /workspace/ComfyUI/custom_nodes # 下载汉化插件 $ git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager
![]()
![]()
输入AIGODLIKE,然后安装:然后重启;
![]()
然后在首页右下角,点击【设置】,找到语言(AGLTranslation-language);选中文就好了
四、下载文生图模型
这里用Flux.1模型;
ComfyUI针对Flux的文档:https://comfyui-wiki.com/zh/tutorial/advanced/flux1-comfyui-guide-workflow-and-examples
# 这里需要进入checkpoints目录
$ cd /workspace/ComfyUI/models/checkpoints
# 用魔塔下载
$ modelscope download --model livehouse/flux1-dev-fp8 --local_dir '/workspace/ComfyUI/models/checkpoints'
如果频繁中断的话,可以本地下载:https://www.modelscope.cn/models/livehouse/flux1-dev-fp8/resolve/master/flux1-dev-fp8.safetensors
然后再上传服务器就好了;

下载完是一个json文件,导入服务器中即可;

选择他:

然后运行工作流即可;
实测98秒可以生成这个效果的图片:
