Negative Prompt in Stable Diffusion

文章介绍了如何使用反向提示词在StableDiffusion2.1版本中改善图像生成效果,特别是对于修复手部细节、去除低质量和模糊等问题。反向提示允许用户告诉模型避免生成某些特征,如额外的手指或模糊的图像,从而增强生成图像的质量和精细度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

漫画中修复手的终极提示词:

正向提示词:

 masterpiece, best quality

best quality, masterpiece, realistic, 16k, ultra detailed, ultra high res, 1girl, full body, skirt

正面提示词:1girl, face_prompt , Pure white background, professional photograph

负面提示词:EasyNegativeV2,(badhandv4:1.2),

ng_deepnegative_v1_75t, bad_prompt_version2-neg, EasyNegative

负向提示词:

EasyNegativeV2

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
disfigured, lowres, bad anatomy, bad hands, text, error, more fingers, extra digit, fewer digits, cropped, worst quality, low quality, jpeg artifacts, signature, watermark,  blurry, bad feet,  bad eye

imgtoimg参数配置:

 修复前后对比效果:

 

必读链接:https://www.reddit.com/r/StableDiffusion/comments/z7salo/with_the_right_prompt_stable_diffusion_20_can_do/

A lot of people have noticed that Negative Prompt works wonders in 2.0, and works even better in 2.1.

Negative hints are the opposite of hints; they allow the user to tell the model what not to generate. Negative cues often remove unwanted details such as injured hands or too many fingers or out-of-focus and blurry images.

You can now easily give negative hints by appending "|" in DreamStudio. <Negative hint>:-1.0" hint. For example, appending "|disfigured, ugly: -1.0, too many fingers: -1.0" occasionally fixes spawning too many fingers.

disfigured, ugly ,too many fingers,too many hands
 


lowres, bad anatomy, bad hands, text,error, missing fngers,extra digt ,fewer digits,cropped, wort quality ,low quality,normal quality, jpeg artifacts,signature,watermark, username, blurry, bad feet
 


NSFW, lowres,bad anatomy,bad hands, text, error, missing fingers,extra digit, fewer digits, cropped, worstquality, low quality, normal quality,jpegartifacts,signature, watermark, username,blurry,bad feet,

加强反向提示词,图像更精致

反向提示词(negative prompt)与提示相反,它允许用户告诉模型不生成什么。

该版本加强了反向提示词的应用,用于消除不需要的细节,进行图像微调,例如手部损坏、手指过多或失焦和图像模煳。

提示:一个美丽的金发女人的肖像,美术摄影、柔和人像拍摄8K、长度中等、超逼真的超高清面部、Unsplash、柯达Ultra Max 800、85毫米胶片、复杂、休闲姿势、中心对称构图、令人惊叹的照片、杰作、颗粒状、居中构图;反向提示:裁剪、低分辨率、画得不好的脸、框架外、画得不好的手、模煳、糟糕的艺术、模煳、文本、水印、毁容、变形、闭眼

用户可以使用加权提示提示模型,对组合中的特定元素进行微调,例如某些颜色、对象或属性。

使用提示加权优化整体图像,以增加或减少合成元素,使用户能够更好地控制图像合成。

根据没有反向提示词(左)和有反向提示词(右)生成图片的比较,可以发现后者在细节方面更加完美。

该图中,反向提示用于告诉模型限制树木、灌木丛、树叶和绿色植物的突出程度,同时保持相同的初始输入提示。

提示:宇航员在一个巨大的未来派金属机甲仓库内的超现实主义绘画,电影、科幻、镜头光晕、光线、史诗、哑光绘画、概念艺术、天体、软渲染、辛烷值渲染、artstation趋势,4k,8k;反向提示:裁剪、低分辨率、帧外、模煳、糟糕的艺术、模煳、文本、毁容、变形

虽然此次版本更新未能完全开放NSFW内容,但并不影响用户使用的热情。毕竟在AIGC领域,Stable Diffusion是当之无愧的顶流。

参考资料:

https://stability.ai/blog/stablediffusion2-1-release7-dec-2022

https://www.reddit.com/r/MachineLearning/comments/zff0bh/p_stable_diffusion_21_release/

### 使用提示矩阵在Stable Diffusion中高效生成不同提示的图像 #### 提示矩阵的概念 提示矩阵允许用户定义多个不同的文本提示组合,从而一次性生成多种变化的图像。这种方法极大地提高了创作效率和多样性。 #### 实现方式 为了实现这一目标,在配置文件或命令行界面中指定一系列分隔符来区分各个独立的提示词组。通常采用竖线`|`作为默认分割符号[^1]: ```plaintext 正面提示 | 变体一 | 变体二 | ... 负面提示 | 不变因素A | 不变因素B | ... ``` 每一对正负向提示之间同样可以加入权重调整因子以微调各成分的影响程度。 #### Python脚本实例 下面是一个简单的Python脚本来展示如何利用API接口批量提交带有不同参数的任务请求并收集返回的结果: ```python import requests from PIL import Image from io import BytesIO def generate_images(api_url, positive_prompts, negative_prompts=None): """ 批量生成基于给定提示列表的图片 参数: api_url (str): API端点地址 positive_prompts (list[str]): 正面提示字符串数组 negative_prompts (list[str], optional): 负面提示字符串数组,默认为空 返回值: list[PIL.Image.Image]: 图片对象集合 """ payload = { "prompt": "\n".join([f"{p}" for p in positive_prompts]), "negative_prompt": "" if not negative_prompts else "\n".join(negative_prompts), "width": 768, "height": 768, "num_inference_steps": 50, "guidance_scale": 7.5, "seed": -1, "batch_size": len(positive_prompts) } response = requests.post(url=api_url, json=payload) images = [] for img_data in response.json()["images"]: image = Image.open(BytesIO(base64.b64decode(img_data))) images.append(image) return images ``` 此函数接受一组或多组正面与负面提示,并通过POST请求发送至指定的服务端进行处理;最终解析响应数据流得到对应的PIL `Image` 对象以便进一步操作或保存到本地磁盘上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

子燕若水

吹个大气球

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值