stable-diffusion真的好用吗?

这篇具有很好参考价值的文章主要介绍了stable-diffusion真的好用吗?。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

hi,各位大佬,今天尝试下diffusion大模型,也是CV领域的GPT,但需要prompt,我给了prompt结果并不咋滴,如下示例,并附代码及参考link

1、img2img

代码实现:

import torch
from PIL import Image

from diffusers import StableDiffusionImg2ImgPipeline

device = "cuda"
model_id_or_path = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe = pipe.to(device)

img_path="girl.jpeg"
init_image = Image.open(img_path).convert("RGB")
init_image = init_image.resize(( 512,768))
#init_image.resize((int(init_image.size[0]*0.6),int(init_image.size[1]*0.6) ))

prompt = "A beautiful hair "

images = pipe(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5).images
images[0].save("beauty.png")

原图及生成的新图对比如下:侵删

stable-diffusion真的好用吗?stable-diffusion真的好用吗?

 woc 网上搜的图,结果搞成这样子,也是服气了。

2、text2img

代码如下:

import torch
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

prompt = "a beautiful girl with blue eyes and long legs and little dress"
#"three girl,chesty"
image = pipe(prompt).images[0]
image.save("generator.png")

stable-diffusion真的好用吗?     

 眼睛都有问题啊,这生成魔鬼可以,生成正常人有点难。

3、带有负向提示词的depth2img

据说哈,提示词越多越好,画得就越好,不然它就比较“自我”,比较随意画了。 

import torch
import requests
from PIL import Image

from diffusers import StableDiffusionDepth2ImgPipeline

pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-depth",
    torch_dtype=torch.float16,
)
pipe.to("cuda")

img_path="seg1.jpeg"#仍旧是第一个网图
init_image = Image.open(img_path)
prompt = "handsome, beautiful, long hair, big eyes, white face"
n_propmt = "bad, deformed, ugly, bad anotomy"

image = pipe(prompt=prompt, image=init_image, negative_prompt=n_propmt, strength=0.7).images[0]

效果不错,除了手指有问题,这个需要加入负向提示词。

stable-diffusion真的好用吗?stable-diffusion真的好用吗?

 负向改为如下,生成上面右图,勉强吧,虽说不上好看,但也没畸形吧。

n_propmt="lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry,bad, cartoon, ugly, deformed"
>>> init_image = Image.open(img_path)
>>> init_image=init_image.resize((int(init_image.size[0]*0.6),int(init_image.size[1]*0.6) ))
>>> image = pipe(prompt=prompt, image=init_image, negative_prompt=n_propmt, strength=0.7).images[0]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 35/35 [00:39<00:00,  1.14s/it]
>>> image.save("seg1_d.png")

因此,对上面的text2img及img2img进行增加上述负向词再次试验,如下:正向词不变

stable-diffusion真的好用吗? stable-diffusion真的好用吗?

text2img(上面右图),必须指明五官方面的词,不能有任何畸形,包括脚,腿,不然太吓人了。

负向提示词改为如下:头都没有了。。。

n_propmt="lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry,bad, cartoon, ugly, deformed,bad face,bad fingers,bad leg,bad shoes, bad feet, bad arm"

stable-diffusion真的好用吗?

上边右图相对正常了,但牙齿不太好,负向词增加“bad teeth”再次尝试,下面的图截断了。

stable-diffusion真的好用吗?

 这也太差劲了吧👎,我勒个去。这要是给客户看到立马滚蛋了。

4、高分辨率的Super-Resolution

import requests
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionUpscalePipeline
import torch

# load model and scheduler
model_id = "stabilityai/stable-diffusion-x4-upscaler"
pipeline = StableDiffusionUpscalePipeline.from_pretrained(
    model_id, revision="fp16", torch_dtype=torch.float16
)
pipeline = pipeline.to("cuda")

# let's download an  image
url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-
init_image = Image.open("seg1.jpeg")
init_image=init_image.resize((int(init_image.size[0]*0.1),int(init_image.size[1]*0.1) ))
prompt = "a white cat"

upscaled_image = pipeline(prompt="a beautiful Chinese girl", image=init_image).images[0]
upscaled_image.save("upsampled_cat.png")

stable-diffusion真的好用吗? 

 压缩后再高分辨率的,为啥到我这里都是翻车呢?

 文章来源地址https://www.toymoban.com/news/detail-425229.html

 

到了这里,关于stable-diffusion真的好用吗?的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 我的stable-diffusion入门

    翻到一个感兴趣的帖子,然后开始了这段折腾 载下来用了,发现用的是cpu出图,慢的很,还是需要stable diffusion webui来做,所以就开始找资料 找模型: https://civitai.com/ https://huggingface.co/ stable diffusion webui:https://github.com/AUTOMATIC1111/stable-diffusion-webui 安装PyTorch详细过程 搭建和配

    2024年04月09日
    浏览(49)
  • Stable-Diffusion 在线部署

    1. 注册 链接:https://aistudio.baidu.com/aistudio/newbie?invitation=1sharedUserId=4982053sharedUserName=2019%E7%9F%A5%E5%90%A6 2. 复制项目: https://aistudio.baidu.com/aistudio/projectdetail/4905623 点击 Fork,复制为自己的项目 3. 点击启动项目 点击“启动环境”,选择合适的 32G版本的GPU,进入项目。 AIStudio 每天

    2024年02月11日
    浏览(39)
  • Stable-Diffusion环境搭建

    硬件可以采用DELL R7525 搭配L4 或者T4 等等企业级显卡   环境如下: 可以看到有相应的GPU卡信息   esxi 7.u3 信息 设置GPU穿透方式    查看相应的虚拟机参数信息  PCI 设备加载穿透GPU信息 启动uefi  设置相应的参数信息 https://docs.nvidia.com/grid/latest/grid-vgpu-release-notes-vmware-vsphere/

    2024年02月09日
    浏览(83)
  • Stable-diffusion复现笔记

    目前正在学习有关扩撒模型的相关知识,最近复现了Stable-diffuison,此文主要是想记录一下整体的复现过程以及我在复现过程中出现的一些奇怪的问题以及我的处理方法。这里我的复现主要是针对官网文档实现的,并没有用到webui版本,如果是想体验Stable-diffusion可以去下载we

    2024年04月09日
    浏览(47)
  • stable-diffusion 学习笔记

    万字长篇!超全Stable Diffusion AI绘画参数及原理详解 - 知乎 参考:stable diffusion提示词语法详解 参考:Ai 绘图日常 篇二:从效果看Stable Diffusion中的采样方法_软件应用_什么值得买 大概示例: 默认是Latent算法:注意该算法在二次元风格时重绘幅度必须必须高于0.5,否则会得到模

    2024年02月20日
    浏览(35)
  • stable-diffusion基础问题记录

    1、启动 如果自己是anaconda,python版本不是3.10.6 conda create -n python_3_10_6 python=3.10.6,创建一个这样的环境 修改webui-user.bat set PYTHON=D:/software/Anaconda3/envs/python_3_10_6/python,把python换成这个版本 然后再启动bat 2、下载gfpgan的时候,如果遇到这种情况:使用国内的网会卡住,使用国外

    2024年02月09日
    浏览(26)
  • CPU硬解Stable-Diffusion

    很多小伙伴说:哎呀!我没有显卡. 哎呀!我显存是AMD的 哎呀!我没有足够的显存 那这一期,将带来CPU和内存运算SD 其实很简单,我们只需要将${COMMANDLINE_ARGS}环境变量设置为--skip-torch-cuda-test 然后在python launch.py后面添加--no-half即可 运行时禁用half 我们来测试一下速度 博主用的CPU很老

    2024年02月11日
    浏览(23)
  • stable-diffusion安装教程推荐

     总结: 安装的时候VPN最重要,安装完成 启动使用stable-diffusion关闭vpn 安装报错都是因为vpn问题,各种安装不了,报错基本上百度都有解决方法 安装看下面两基本上够了 Windows安装Stable Diffusion WebUI及问题解决记录_暂时先用这个名字的博客-CSDN博客 Stable-Diffusion和ControlNet插件安

    2024年02月06日
    浏览(45)
  • stable-diffusion AI 绘画

    git clone https://github.com/CompVis/stable-diffusion.git 进入stable-diffusion目录 在这里注册一个账号: Hugging Face – The AI community building the future. 并生成个token 安装CUDA NVIDIA 安装 CUDA_nvidia cuda_长满头发的程序猿的博客-CSDN博客 pip install torch -f https://download.pytorch.org/whl/torch_stable.html pip insta

    2024年02月13日
    浏览(37)
  • stable-diffusion代码和应用

    代码:这里面介绍几种stable-diffusion的代码版本之类的。 1.stable-diffusion-webui GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI 这个版本主要是webui框架实现,webui由gradio实现,如果本地没有gpu就别搞了,这里面的stable-diffusion实现了prompt和negative prompt。 2.stable-diffusion-compvi

    2024年02月09日
    浏览(28)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包