Posted in

消费级显卡,17G 显存,玩转图像生成模型 FLUX.1!_AI阅读总结 — 包阅AI

包阅导读总结

1.

“`

FLUX.1、图像生成模型、消费级显卡、stable diffusion、ComfyUI

“`

2.

FLUX.1 是由 stable diffusion 部分核心开发者推出的全新图像生成模型,与 SD3 有相似处和区别。它在多种能力上效果良好,提供三种型号,开源了部分权重。文中还介绍了在消费级显卡上基于 ComfyUI 使用 FLUX 模型的流程,包括下载部署、模型下载等。

3.

– 图像生成模型 FLUX.1

– 由 stable diffusion 部分核心开发者推出

– 与 SD3 架构相似与不同

– 在多种能力上表现出色

– FLUX.1 型号与开源

– 提供三种型号及链接

– 开源部分权重及协议

– 在消费级显卡上使用 FLUX.1

– 基于 ComfyUI

– 下载和部署 ComfyUI 及相关依赖

– 下载多种模型

– 使用 cloudflared 运行

– 加载流程图

– 展示效果案例及体验链接

思维导图:

文章地址:https://mp.weixin.qq.com/s/E6dEz8wVThsK5jJvTrYx4w

文章来源:mp.weixin.qq.com

作者:社恐患者杨老师等

发布时间:2024/8/2 12:38

语言:中文

总字数:1389字

预计阅读时间:6分钟

评分:91分

标签:图像生成模型,FLUX.1,消费级显卡,AI生成内容,模型开源


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

近期stable diffusion的部分核心开发同学,推出了全新的图像生成模型FLUX.1

从模型架构上看,FLUX.1和SD3有很多相似之处,都是基于FlowingMatching调度的模型,都通过引入T5来增强prompt的依从性。而比较显著的区别在于:flux模型引入了一种叫DoubleStreamBlock的结构,具体来说在前几层layer中,采用了txt和img embedding独立过各自的transformer块,然后再拼到一起过统一的transformer块,我们推测是为了进一步对齐图像和文本特征,但是这部分还没有更具体的技术报告。


FLUX.1在文本控制能力,多主体生成能力,手部生成能力等取得了很好的效果。


FLUX.1提供三种型号:

模型版本

模型链接

License

FLUX.1 [schnell]

https://modelscope.cn/models/AI-ModelScope/FLUX.1-schnell

apache-2.0

FLUX.1 [dev]

https://modelscope.cn/models/AI-ModelScope/FLUX.1-dev

FLUX.1-dev Non-Commercial License

FLUX.1 [pro]

仅可通过API访问


AutoDecoder的权重也在模型repo中一起开源,且开源协议为Apache-2.0。


因为dev版本模型size达到12B,为了可以在消费级显卡使用,社区开发者也分享了fp8版本。


fp8模型链接:https://modelscope.cn/models/AI-ModelScope/flux-fp8

代码链接:https://github.com/black-forest-labs/flux

非常感谢阿里muse团队的魔搭体验链接!

体验链接:https://www.modelscope.cn/studios/muse/flux_dev

小程序也可以体验哦!


除了在魔搭创空间上直接体验之外,这里我们提供基于ComfyUI的FLUX模型上手使用体验。ComfyUI是一个功能强大、模块化程度高的AIGC图形和视频生成的用户界面和后台。本文使用ComfyUI,在魔搭社区提供的免费GPU Notebook上,体验FLUX模型的使用:

下载和部署ComfyUI

clone代码,并安装相关依赖:


from pathlib import Path
OPTIONS = {}
UPDATE_COMFY_UI = True WORKSPACE = 'ComfyUI'OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI
WORKSPACE = "/mnt/workspace/ComfyUI"%cd /mnt/workspace/
![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI%cd $WORKSPACE
if OPTIONS['UPDATE_COMFY_UI']: !echo -= Updating ComfyUI =- !git pull
!echo -= Install dependencies =-

模型下载

#@markdown ###Download standard resources
### FLUX1-DEV!modelscope download --model=AI-ModelScope/FLUX.1-dev --local_dir ./models/unet/ flux1-dev.sft!modelscope download --model=AI-ModelScope/flux-fp8 --local_dir ./models/unet/ flux1-dev-fp8.safetensors

### Download text encoder model!modelscope download --model=AI-ModelScope/flux_text_encoders --local_dir ./models/clip/ t5xxl_fp16.safetensors!modelscope download --model=AI-ModelScope/flux_text_encoders --local_dir ./models/clip/ clip_l.safetensors!modelscope download --model=AI-ModelScope/flux_text_encoders --local_dir ./models/clip/ t5xxl_fp8_e4m3fn.safetensors

### vae!modelscope download --model=AI-ModelScope/FLUX.1-dev --local_dir ./models/vae/ ae.sft

使用cloudflared运行ComfyUI

!wget "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/cloudflared-linux-amd64.deb"!dpkg -i cloudflared-linux-amd64.deb
import subprocessimport threadingimport timeimport socketimport urllib.request
def iframe_thread(port): while True: time.sleep(0.5) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = sock.connect_ex(('127.0.0.1', port)) if result == 0: break sock.close() print("\nComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\n")
p = subprocess.Popen(["cloudflared", "tunnel", "--url", "http://127.0.0.1:{}".format(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE) for line in p.stderr: l = line.decode() if "trycloudflare.com " in l: print("This is the URL to access ComfyUI:", l[l.find("http"):], end='') #print(l, end='')

threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()
!python main.py --dont-print-server

Load流程图

flux1-dev流程图:

https://modelscope.oss-cn-beijing.aliyuncs.com/resource/flux1-dev-test.json


flux1-schnell流程图:

https://modelscope.oss-cn-beijing.aliyuncs.com/resource/flux1-schnell-test.json


流程图上具体配置如下:

简单 Prompt

复杂 Prompt

a bear standing on a car, sunset, winter

a boy and a girl, the boy stands at the left side, the boy wears a red t-shirt and blue pants, the girl wears a green t-shirt and pink pants.

the apple is in the box, the box is on the chair, the chair is on the desk, the desk is in the room

多实体生成能力很能打,颜色能做到分别控制,空间关系还算OK

多风格

Chinese ink painting, a girl, long hair, colorful hair, shining eyes

oil painting, a girl, long hair, colorful hair, shining eyes

anime, a girl, long hair, colorful hair, shining eyes

风格上,个人认为风格属性一般。比如没有很好理解中国水墨画风格。

文本

a car, the number is NT352K

A capybara is holding up a sign that says ‘ModelScope’

A boy is holding up a sign that says ‘I am an AI engineer!’

能处理较长英文文本,可以展示换行文本,依然需要cherry pick,但成功率非常高。

多样性

sunset over the sea

sunset over the sea

sunset over the sea

没有训死,多样性还在


tag未来是否还需要?

还有一个好玩的case,提示词里加了 best quality,然后它真的标了个 best quality。

点击阅读原文,直达体验链接。