Featured image of post 【免费・超简单】使用Stable Diffusion生成式AI插画的方法!Google Colab步骤分析

【免费・超简单】使用Stable Diffusion生成式AI插画的方法!Google Colab步骤分析

想不想尝试使用能根据输入的文字生成高质量图片的AI“Stable Diffusion”,创作出您喜欢的插画呢?本文将详细讲解仅需Google Colab和免费账号,任何人都能轻松开始AI图片生成的步骤。

什么是 Stable Diffusion

Stable diffusion是由德国慕尼黑大学研究团队开发的,根据输入的文本信息生成图片的AI。 通过让其学习各种图片,它可以生成从写实到插画的各种图片。

这次,我将介绍如何使用Stable diffusion的预训练数据生成插画图片。

准备工作

  • Google账号

只需要这个。

生成步骤

  1. 打开 https://colab.research.google.com
  2. 选择左上角文件中的新建笔记本
  3. 选择编辑中的笔记本设置
  4. 硬件加速器更改为GPU img_2.png
  5. 粘贴并运行以下代码
1
!pip install diffusers==0.8.0 transformers
  1. 粘贴并运行以下代码
1
from diffusers import StableDiffusionPipeline
  1. 粘贴并运行以下代码
1
2
pipe = StableDiffusionPipeline.from_pretrained("gsdf/Counterfeit-V2.5")
pipe.to("cuda")
  1. 粘贴并运行以下代码
1
2
3
4
5
prompt = "((masterpiece,best quality)),1girl, solo, animal ears, rabbit, barefoot, knees up, dress, sitting, rabbit ears, short sleeves, looking at viewer, grass, short hair, smile, white hair, puffy sleeves, outdoors, puffy short sleeves, bangs, on ground, full body, animal, white dress, sunlight, brown eyes, dappled sunlight, day, depth of field"
n_prompt = "EasyNegative, extra fingers,fewer fingers"

image = pipe(prompt, negative_prompt = n_prompt).images[0]
image

这里使用的Prompt参考了https://huggingface.co/gsdf/Counterfeit-V2.5Prompt

生成结果(部分)

img_1.png

img_3.png

img_4.png

参考

comments powered by Disqus