只需要输入一句话,AI帮你生成漂亮的艺术图片

新野1年前 ⋅ 1311 阅读

可以根据文字生成图片的模型。只要输入一段文字描述,就能得到一张由 AI 生成的图片,除此之外该项目还支持将粗糙的草图转化成精致的艺术图片。

https://github.com/CompVis/stable-diffusion

# make sure you're logged in with `huggingface-cli login`
from torch import autocast
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
	"CompVis/stable-diffusion-v1-4", 
	use_auth_token=True
).to("cuda")

prompt = "a photo of an astronaut riding a horse on mars"
with autocast("cuda"):
    image = pipe(prompt)["sample"][0]  
    
image.save("astronaut_rides_horse.png")

# make sure you're logged in with `huggingface-cli login`
from torch import autocast
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
	"CompVis/stable-diffusion-v1-4", 
	use_auth_token=True
).to("cuda")

prompt = "a photo of an astronaut riding a horse on mars"
with autocast("cuda"):
    image = pipe(prompt)["sample"][0]  
    
image.save("astronaut_rides_horse.png")


生成4个同系列图片菜单

全部评论: 0

    相关推荐