stable-diffusion真的好用吗?

news2024/10/5 17:17:34

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")

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

 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")

     

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

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]

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

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

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进行增加上述负向词再次试验,如下:正向词不变

 

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"

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

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

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")

 

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

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/424929.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

PageHelper的使用

这个分页插件是在Mybatis的环境中使用的&#xff0c;所以项目需要导入Mybatis依赖 更加详细的用法看官方文档&#xff1a;PageHelper官网 在Mybatis中使用 前提条件 引入依赖 <dependency><groupId>com.github.pagehelper</groupId><artifactId>pa…

GANs和Generative Adversarial Nets和Vox2Vox: 3D-GAN for Brain Tumour Segmentation

参考&#xff1a; 各种生成模型&#xff1a;VAE、GAN、flow、DDPM、autoregressive models https://blog.csdn.net/zephyr_wang/article/details/126588478李沐GAN精度 x.1 生成模型家族 DGMs&#xff08;Deep Generatitve Models&#xff09;家族主要有&#xff1a;GAN&…

数据分析的目的和意义是什么?_光点科技

数据分析是一个越来越受到关注的领域&#xff0c;因为它可以帮助企业和组织利用数据来制定更明智的决策。数据分析的目的和意义是多方面的&#xff0c;例如&#xff1a; 1.了解客户需求 数据分析可以帮助企业更好地了解客户需求&#xff0c;从而制定更准确的市场营销策略。通过…

原生JS + HTML + CSS 实现快递物流信息 API 的数据链式展示

引言 全国快递物流查询 API 是一种提供实时、准确、可靠的快递物流信息查询服务的接口。它基于现有的物流信息系统&#xff0c;通过API接口的方式&#xff0c;向用户提供快递物流信息的查询、跟踪、统计等功能。使用全国快递物流查询 API&#xff0c;用户可以在自己的应用程序…

[2021 东华杯]bg3

Index介绍漏洞利用过程一.泄露Libc二.Tcache Bin Attack三.完整EXP介绍 [2021 东华杯]bg3 本题是C写的一道经典菜单堆题&#xff0c;拥有增删改查全部功能。 Bug DataBase - V3.0 - I think i am UnBeatAble 1. Upload A Bug 2. Change A Uploaded Bug 3. Get Uploaded Bug D…

企业大数据湖总体规划及大数据湖 一体化运营管理建设方案

背景&#xff1a;数据快速入湖&#xff0c;分析更加智能&#xff0c;应用更加多样&#xff0c;服务更加开放更多企业数据将进入数据湖&#xff0c;来自传统系统的数据和传感器等新型数据资源不断融合&#xff0c;数据孤岛将继续被打破。随着大数据分析能力的不断提高&#xff0…

借助Nacos配置中心实现一个动态线程池

目录 一、实现思路 二、实现说明概览 三、代码实现 DynamicThreadPool RejectedProxyInvocationHandler DynamicThreadPoolRegister DynamicThreadPoolRefresher 测试动态线程池 平常我们系统中定义的一些线程池如果要想修改的话&#xff0c;需要修改配置重启服务才能生…

『pyqt5 从0基础开始项目实战』05. 按钮点击事件之添加新数据 (保姆级图文)

目录导包和框架代码给按钮绑定一个点击事件获取输入框的数据多线程与界面更新&#xff08;新线程与UI更新的数据交互&#xff09;代码结构完整代码main文件Threads.py总结欢迎关注 『pyqt5 从0基础开始项目实战』 专栏&#xff0c;持续更新中 欢迎关注 『pyqt5 从0基础开始项目…

上海亚商投顾:沪指创年内新高 大金融、中字头集体走强

上海亚商投顾前言&#xff1a;无惧大盘涨跌&#xff0c;解密龙虎榜资金&#xff0c;跟踪一线游资和机构资金动向&#xff0c;识别短期热点和强势个股。 市场情绪 沪指今日低开高走&#xff0c;午后涨超1%&#xff0c;创出近10个月以来新高&#xff0c;创业板指走势较弱&#xf…

不走弯路,AI真的能提高生产效率

AI应用虽然取得了令人瞩目的成果&#xff0c;但是在实际应用中仍存在不少困境。市面上不乏有AI绘画、AI写作、AI聊天的相关产品&#xff0c;即使Chatgpt可以写代码、写论文&#xff0c;但由于技术的有限性&#xff0c;还需要不断地优化完善才能给出更精准的答复&#xff0c;也少…

契约锁与多家软件行业伙伴达成战略合作,携手助力组织数字化转型

近日&#xff0c;契约锁电子签章与天翼云、神州数码、同望科技、宏灿软件、甄零科技、正量科技等多家软件行业伙伴达成战略合作&#xff0c;充分发挥各自专业与资源优势&#xff0c;从产品、市场、销售、技术等多方面展开深度合作&#xff0c;共同为客户提供全程数字化解决方案…

zabbix创建自定义监控模板

目录 第一章先行配置zabbix 第二章配置自定义 2.1.案列&#xff1a;自定义监控客户端服务器登录的人数需求&#xff1a;限制登录人数不超过 3 个&#xff0c;超过 3 个就发出报警信息 2.2.在 Web 页面创建自定义监控项模板 2.3.zabbix 自动发现与自动注册 总结 自定义监控…

【论文精度(李沐老师)】Generative Adversarial Nets

Abstract 我们提出了一个新的framework&#xff0c;通过一个对抗的过程来估计生成模型&#xff0c;其中会同时训练两个模型&#xff1a;生成模型G来获取整个数据的分布&#xff0c;辨别模型D来分辨数据是来自于训练样本还是生成模型G。生成模型G的任务是尽量的让辨别模型D犯错…

DI依赖注入

DI依赖注入Setter注入setter注入引用类型setter注入简单类型&#xff08;基本数据类型和字符串&#xff09;构造器注入构造器注入引用类型自动装配集合注入首先我们明确一些观点1、注入的Bean的数据包括引用类型与简单类型&#xff08;基本数据类型和字符串&#xff09;2、通过…

HTML5 地理定位

HTML5 Geolocation&#xff08;地理定位&#xff09; HTML5 Geolocation&#xff08;地理定位&#xff09;用于定位用户的位置。 Geolocation 通过请求一个位置信息&#xff0c;用户同意后&#xff0c;浏览器会返回一个包含经度和维度的位置信息&#xff01; 定位用户的位置 …

【C语言数组部分】

数组部分综述引入&#xff1a;数组概念&#xff1a;一、一维数组1.1一维数组的创建&#xff1a;1.2一维数组的初始化&#xff1a;1.2.1初始化概念&#xff1a;1.2.2完全初始化&#xff1a;1.2.3不完全初始化&#xff1a;1.3字符数组的初始化&#xff1a;1.3.1用字符初始化&…

如何解决spring的循环依赖问题?

前言 昨天我们说了什么是spring的循环依赖&#xff0c;以及产生的原因&#xff0c;今天那我们就来说说如何解决spring的循环依赖问题。 上篇文章说到过&#xff0c;只有通过setter方法进行依赖注入且是在单例模式下产生的循环依赖问题是被解决的&#xff1f; Spring是怎样解决…

rhce第二次作业

配置ssh免密登陆&#xff0c;能够通过客户端主机通过redhat用户和服务端主机基于公钥验证方式进行远程连接 [root456 ~]# hostname host [root456 ~]# bash \\更改名称[roothost ~]# su redhat …

2023年腾讯云S5云服务器性能网络收发包PPS、连接数、内网带宽能力等性能测评

腾讯云服务器标准型S5实例CPU采用Intel Xeon Cascade Lake或者Intel Xeon Cooper Lake处理器&#xff0c;主频2.5GHz&#xff0c;睿频3.1GHz&#xff0c;标准型S5云服务器基于全新优化虚拟化平台&#xff0c;配有全新的Intel Advanced Vector Extension (AVX-512) 指令集&#…

微服务+springcloud+springcloud alibaba学习笔记【Spring Cloud服务网关】(7/9)

Spring Cloud服务网关 7/91、GateWay概述2、GateWay的特性:3、GateWay与zuul的区别:4、zuul1.x的模型:5、什么是webflux:6、GateWay三大概念:6.1,路由:6.2,断言:6.3,过滤:7、GateWay的工作原理:8、使用GateWay:8.1,建module8.2,修改pom文件8.3,写配置文件8.4,主启动类8.5,针对p…