如何使用Stable Diffusion制作艺术二维码

如何使用Stable Diffusion制作艺术二维码

By Shawn Less

研究比较火的艺术二维码图片生成,并在本机使用cpu跑两张二维码,使用Stable Diffusion及ControlNet插件。

1.生成原始二维码图片

生成原始二维码地址

本地图片

2.搭建stable-diffusion-webui

使用Stable Diffusion需要调试参数所以在本地使用stable-diffusion-webui搭建,文档如下:

stable-diffusion-webui

注意如果电脑没有gpu,需要修改/stable-diffusion-webui/webui-user.bat脚本,使用cpu运行 set COMMANDLINE_ARGS= —lowvram —precision full —no-half —skip-torch-cuda-test

3.下载checkpoint

ghostmix checkpoint

下载好放到\stable-diffusion-webui\models\Stable-diffusion目录中 在webui中可以看到如下图:

本地图片

其他checkpoint:

4.安装controlnet插件

要使用ControlNet需要安装,ControlNet非常好玩可以做很多东西后续深入研究,文档如下:

Control Net

步骤:

  • 1.打开 “Extensions”选项卡。
  • 2.在标签中打开 “Install from URL”标签。
  • 3.输入https://github.com/Mikubill/sd-webui-controlnet.git 到 “URL for extension’s git repository”。
  • 4.按 “Install”按钮。
  • 5.等待5秒钟,你会看到 “Installed into stable-diffusion-webui/extensions\sd-webui-controlnet. 使用 “Installed”选项卡重新启动”。
  • 6.进入 “Installed”选项卡,点击 “Check for updates”,然后点击 “Apply and restart UI”(下次你也可以使用这些按钮来更新控制网)。
  • 7.重新启动A1111 webui

本地图片

5.下载模型

Control Model

使用到control_v11f1e_sd15_tile.pth模型
放到\stable-diffusion-webui\extensions\sd-webui-controlnet\models

6.生成艺术二维码

a. 选择GhostMix checkpoint
b. 选择img2img
c. 输入Prompt

a cubism painting of a town with a lot of houses in the snow with a sky background, Andreas Rocha, matte painting concept art, a detailed matte painting

d. 输入negative prompt

ugly, disfigured, low quality, blurry, nsfw

e. 上传生成好的原始二维码图片
f. 设置img2img选项

  • Resize mode: Just resize
  • Sampling method: DPM++2M Karras
  • Sampling step: 50
  • Width: 768
  • Height: 768
  • CFG Scale: 7
  • Denoising strength: 0.75

g. 在ControlNet里上传原始二维码图片
h. 设置ControlNet选项

  • Enable: Yes
  • Control Type: Tile
  • Preprocessor: tile_resample
  • Model: control_xxx_tile
  • Control Weight: 0.87
  • Starting Control Step: 0.23
  • Ending Control Step: 0.9

i. 生成

本地图片

房子参数:

a cubism painting of a town with a lot of houses in the snow with a sky background, Andreas Rocha, matte painting concept art, a detailed matte painting Negative prompt: ugly, disfigured, low quality, blurry, nsfw Steps: 50, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 2194810646, Size: 768x768, Model hash: e3edb8a26f, Model: ghostmix_v20Bakedvae, Denoising strength: 0.7, ControlNet: “preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 1, starting/ending: (0.24, 0.9), resize mode: Crop and Resize, pixel perfect: False, control mode: Balanced, preprocessor params: (-1, 1, -1)”, Version: v1.3.2

本地图片

机器人参数:

light, futobot, cyborg, ((masterpiece),(best quality),(ultra-detailed), (full body:1.2), 1male, solo, hood up, upper body, mask, 1boy, male focus,white gloves, cloak, long sleeves, spaceship, lightning, hires Negative prompt: ugly, disfigured, low quality, blurry Steps: 50, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 2284077713, Size: 768x768, Model hash: e3edb8a26f, Model: ghostmix_v20Bakedvae, Denoising strength: 0.7, ControlNet: “preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 1, starting/ending: (0.2, 1), resize mode: Crop and Resize, pixel perfect: False, control mode: Balanced, preprocessor params: (-1, 1, -1)”, Version: v1.3.2

本地图片

使用本机cpu跑实在太慢,2两个小时才能跑出来一张艺术二维码图片,就不继续跑,后续搞个有gpu的机器跑。

参数说明:

  • Denoising strength :降低初始成分更多地遵循QR码。 但是如果你减少太多,你只会看到二维码。 它通常设置为高于 0.7。
  • Control Weight :减少以显示更多提示。
  • Starting Control Step : 增加以显示更多提示。
  • Ending Control Step :减少以更早停止ControlNet,以便QR码和图像可以更自然地融合。
因为生成的图片不一定都可以扫描出二维码,可以调整上面的参数直到达到要求。

文章参考: