AI 绘画快速开始-StableDiffusionWebui

2023-12-13 09:44

本文主要是介绍AI 绘画快速开始-StableDiffusionWebui,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

    • 介绍
    • WebUI 的安装和部署
    • 参数介绍
    • Prompt技巧
      • 初阶Prompt:直接描述的精细化
      • 二阶Prompt:巧用标签的扩展
      • 三阶Prompt:负面提示词的深入应用
      • 四阶Prompt:文本权重调整的细化
      • 引入 LoRA:模型特效的创新应用
    • 案例-生成漫画 (LoRA)
      • 分镜1: 出发
      • 分镜2: 火车站
      • 分镜3: 古城探险
      • 分镜4: 山川间
      • 分镜5: 海边日落
      • 分镜6: 夜市灯光

介绍

Stable Diffusion web UI是一个基于Gradio库的Stable Diffusion图像生成的网页接口。

Stable Diffusion是一个使用深度学习对文本进行图像生成的系统。它由Anthropic公司开发,基于 transformer 得到快速发展。

这个网页界面利用 Gradio 库,将 Stable Diffusion 应用到一个可视化的网页应用中。用户可以通过简单的提示文本生成高质量的图像。

该项目的主要功能和特性包括:

  • 原始的文字到图像和图像到图像生成模式
  • 一键安装和运行脚本,方便用户快速上手
  • 支持扩充生成、修复补全等功能
  • 丰富的调节生成参数的界面
  • 支持多个后处理模型提升生成图片质量
  • 训练自定义嵌入向量等功能
  • 社区提供的各种扩展脚本
  • 优化的推理速度,可以在低显存环境运行
    该项目由 Github 用户 AUTOMATIC1111 创建和维护,采用 AGPL-3.0 开源协议。它极大地方便了Stable Diffusion在本地机器上的部署使用,提供了丰富的功能,是基于该模型的图像生成的首选工具之一。一个活跃的社区为其不断新增功能和维护。

WebUI 的安装和部署

参考https://github.com/AUTOMATIC1111/stable-diffusion-webui.git 安装部署

参数介绍

  • Prompt - 文本提示,用于描述目标生成图像的内容、样式等信息。
  • Negative Prompt - 排除的文本,用于指出不希望在生成图像中出现的内容。
  • Steps - 图像生成的迭代步数,步数越多图像质量越高。
  • Sampling Method - 采样方法,不同方法会影响图像质量和样式。
  • Seed - 随机种子数,用于控制生成结果的多样性。
  • Size - 生成图片的分辨率大小。
  • Model - 选择使用的Stable Diffusion模型变量。
  • Strength - 指导生成图片符合提示的强度。
  • Scale - 控制生成图片样式的缩放程度。
  • CFG Scale - 控制文本编码器输出的缩放比例。
  • Batch Size - 同时生成的图片数量。
  • Batch Count - 生成的批次数量。
  • 文本到图像(txt2img) - 这是最基础的功能,可以直接在Prompt框中输入文本描述,生成对应图像。支持控制风格、内容等。
  • 图像到图像(img2img) - 可以输入一张图像,经过模型处理生成修订版本。支持补全、扩充、调整样式等。
  • Outpainting - 基于一张图像,扩充图像边界区域,生成更大尺寸的图片。
  • Inpainting - 修复图像中遮挡或损坏的区域,使图片完整。
  • Color Sketch - 输入素描画,生成对应颜色图片。
  • Stable Diffusion Upscale - 使用模型进行图片超分辨率处理。
  • Attention - 通过特殊语法强调文本中的重点内容,模型会聚焦在这些部分。
  • Prompt Matrix - 通过矩阵排列不同prompt,自动生成图片网格。
  • 循环生成(Loopback) - 将图片循环多次输入模型,实现图像迭代优化。
  • 故障检测(CLIP Interrogator) - 分析图像判断最可能的生成提示。
  • 无缝处理(Seamless) - 自动处理生成图片边界,实现无缝拼接。

Prompt技巧

初阶Prompt:直接描述的精细化

  • 在描述时,尽量具体化。例如,不仅是 “a happy dog and a cute girl”,而是 “a joyful golden retriever playing with a smiling girl in a sunny park”。这样的详细描述能帮助模型更准确地捕捉您的创作意图。

二阶Prompt:巧用标签的扩展

  • 现在让我们进一步提升这幅画的质量,方法就是使用标签(tag)继续优化。best quality, masterpiece, a happy dog and a cute girl, watercolor style。 除了 “best quality” 和 “masterpiece”,可以加入更具体的艺术风格或细节描述,如 “vibrant colors, intricate details”。例如,“vibrant colors, intricate details, best quality, masterpiece, a happy dog and a cute girl, watercolor style”。
  • 延伸内容:探索不同艺术流派的标签,如 “impressionist, surrealism, or baroque style”,以及特定艺术家的风格,如 “in the style of Van Gogh or Picasso”。

三阶Prompt:负面提示词的深入应用

  • 在使用负向提示词时,可以更具体地指出不希望出现的元素,如 “no crowds, avoid oversaturation, no photorealism”。
  • 延伸内容:利用负面提示词来排除常见的AI生成错误,如 “no floating objects, no mismatched perspectives”。

四阶Prompt:文本权重调整的细化

  • 使用括号来强调特定元素时,可以结合形容词增强效果,如 “a happy (big dog) and a (tiny cute girl), watercolor style”。
  • 延伸内容:尝试对比不同权重下的效果,如 “(dog:1.5) and (girl:0.5)”,来控制图像中元素的相对重要性。

引入 LoRA:模型特效的创新应用

  • 在使用 LoRA 时,确保模型文件名和权重适当匹配您的创作目标,如 “lora:artistic_model:1.2”。
  • 延伸内容:实验不同的 LoRA 模型来探索各种视觉效果,如 “lora:cinematic_effect:1.0” 或 “lora:dreamy_landscape:1.5”,以创造独特的艺术作品。

案例-生成漫画 (LoRA)

LoRA(Long Range Arena)是一种用于图像生成的新方法,其基本原理如下:

  • LoRA 使用了与Stable Diffusion类似的Diffusion模型结构,包括Encoder,Decoder,UNet等组件。
  • LoRA 提出了一种新的自回归(Auto-regressive)策略,可以capture更长范围的依赖关系。
  • 在训练阶段,LoRA 通过预测序列中远距离的token来进行训练,而不是只预测相邻的token。
  • 在推理阶段,LoRA 通过采样不同步长的序列,合并为完整的序列,从而实现了更长范围的依赖建模。
  • LoRA还设计了一种类似Transformer的跨层Attention机制,不同层之间可以建立依赖关系。
    通过上述特点,LoRA可以model更丰富的长程依赖,生成更连贯、合理的图像。

用的Base Model https://civitai.com/models/9409?modelVersionId=30163

用LoRA https://civitai.com/models/88201?modelVersionId=93864

在构建一个漫画分镜故事,可以采取一种简单的叙述流程,以讲述一个小女孩旅行的故事。以下是一种可能的分镜顺序:

分镜1: 出发

  • 画面: 小女孩背着一个大背包站在家门口。她的猫咪在她的脚边,仰头望着她。
  • 文字: “小丽准备好了她的冒险,家门口的告别总是有些苦涩。”
  • prompt
A little girl stands at the doorway of her home, ready for an adventure. She has a large backpack that is almost as big as her tiny frame. By her feet sits her fluffy orange cat, gazing up at her with curious eyes. Gentle light catches on the girl's windblown hair and shining eyes, full of excitement and optimism. Her cat's fur ripples in the breeze. Lush greenery and colorful flowers surround the simple home's exterior. A path leads from the door into a sunny day filled with possibilities. Digital painting, peaceful atmosphere, childhood wonder, bond between girl and pet, smooth skin, lifelike fur, vivid yet calming colors, finely rendered details, illustrative style <lora:Iku_Nakatani:1>
  • negative prompt
EasyNegative, (worst quality, low quality:1.4), (lip, nose, rouge, lipstick:1.4), (jpeg artifacts:1.4), (1boy, abs, muscular:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature

分镜2: 火车站

  • 画面: 小女孩坐在火车站的长椅上,一边看着手中的火车票,一边期待地望向铁轨。
  • 文字: “火车站人来人往,小丽的心中充满了即将启程的激动。”
  • prompt
A young girl sits pensively on a wooden bench at a small train station, the late afternoon light casting a warm glow over her features. In her small hands she clutches an tickets, tracing over the letters and numbers with her fingertips as she gazes expectantly down the railroad tracks. Ripples in the ties lead the eye into the distant point where sky meets earth. A gentle breeze tousles the girl's hair as birdsong and the rumble of a distant locomotive are carried on the wind. A sense of anticipation and excitement mingles with the stillness of waiting as the moments tick by. Digital painting, atmospheric perspective, nostalgic mood, attention to tiny details, emotionally evocative light and colors, smooth skin, textured surfaces, inviting the viewer to share in the girl's wondering thoughts <lora:Iku_Nakatani:1>
  • negative prompt
EasyNegative, (worst quality, low quality:1.4), (lip, nose, rouge, lipstick:1.4), (jpeg artifacts:1.4), (1boy, abs, muscular:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature 

分镜3: 古城探险

  • 画面: 小女孩站在一座古老城堡的巨大城门前,眼睛充满好奇。
  • 文字: “古城的神秘召唤着小丽,每块石头都诉说着历史的故事。”
  • prompt
A young girl gazes up at immense castle gates that block her view inside. Moss clings to weathered stones taller than any building she's seen. Two wooden doors stand closed yet unbarred. Sunlight catches motes of dust as ravens call from high above. Curiosity swells within her at the mysteries the old walls hide. What wonders and legends wait within those towering walls for an adventurous visitor to discover? <lora:Iku_Nakatani:1>
  • negative prompt
EasyNegative, (worst quality, low quality:1.4), (lip, nose, rouge, lipstick:1.4), (jpeg artifacts:1.4), (1boy, abs, muscular:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature 

分镜4: 山川间

  • 画面: 小女孩在翠绿的山谷中跳跃,手臂张开,仿佛整个世界都在欢迎她。
  • 文字: “绿意盎然的山谷中,小丽感受自然的力量和美丽。”
  • prompt
A young girl spins and twirls amidst a lush green valley, arms outstretched as if to embrace the vibrant natural surrounds. Golden sunlight dances over her smiling face and through the leaves, illuminating her carefree glee. Grasses and wildflowers sway to the rhythm of her dancing feet, partners in her play.Butterflies flit amid the shimmering foliage as dancing shadows cast dancing girls upon the hills. Laughter floats upon the breeze like birdsong through towering trees. No sound but for the gurgling brook can match the girl's tuneless melody of mirth.Here, surrounded by the valley's verdant embrace, she is queen of her own private realm, filled with the wonders and joy of youth. Golden light gilds petals, pollen, and peasant's hair alike, a living child amidst a living tapestry of delight. <lora:Iku_Nakatani:1>
  • negative prompt
EasyNegative, (worst quality, low quality:1.4), (lip, nose, rouge, lipstick:1.4), (jpeg artifacts:1.4), (1boy, abs, muscular:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature 

分镜5: 海边日落

  • 画面: 小女孩坐在沙滩上,眼睛注视着海平线上的落日。
  • 文字: “金色的夕阳与海的边界相遇,小丽被这壮丽的景色深深吸引。”
  • prompt
Young girl sitting on the beach, gazing at the sunset on the horizon, warm orange and pink hues reflecting off her skin and clothing, sandy feet buried in the shore, windswept hair gently blowing in the breeze, delicate features peacefully illuminated in the dying light, intricate details in the folds of her sundress and textures of the sand, elegant composition, smooth colors blended seamlessly, highly realistic digital painting style, art by Greg Rutkowski and Alphonse Mucha <lora:Iku_Nakatani:1>
  • negative prompt
EasyNegative, (worst quality, low quality:1.4), (lip, nose, tooth, rouge, lipstick, eyeshadow:1.4), (jpeg artifacts:1.4), (bokeh, blurry, film grain, chromatic aberration, lens flare:1.0), (1boy, abs, muscular, rib:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature, simple background, white background

分镜6: 夜市灯光

  • 画面: 小女孩走在热闹的夜市中,周围是各种摊位和闪烁的灯笼。
  • 文字: “五彩斑斓的灯光下,小丽在夜市中尝试着各种美食,每一口都是新鲜的体验。”
  • prompt
Young girl wandering through a bustling night market, vibrant stalls and flashing paper lanterns lining the alleyway on both sides, colorful lights dancing off her excited face as she takes in the lively atmosphere, delicate features and flowing sundress elegantly illuminated amidst the hustle and bustle, intricate woven details in the tapestries and fabrics fluttering overhead, smooth blending of warm tones capturing the joyful energy, highly realistic digital painting style, art by Greg Rutkowski and Alphonse Mucha <lora:Iku_Nakatani:1>
  • negative prompt
EasyNegative, (worst quality, low quality:1.4), (lip, nose, tooth, rouge, lipstick, eyeshadow:1.4), (jpeg artifacts:1.4), (bokeh, blurry, film grain, chromatic aberration, lens flare:1.0), (1boy, abs, muscular, rib:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature, simple background, white background

每个分镜都突出了旅行的一个特定阶段,从准备出发到探索新地方,再到旅途的回忆。这种结构能够帮助读者跟随小女孩的旅行经历,感受她的情感起伏。

在这里插入图片描述

这篇关于AI 绘画快速开始-StableDiffusionWebui的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/487983

相关文章

使用EasyPoi快速导出Word文档功能的实现步骤

《使用EasyPoi快速导出Word文档功能的实现步骤》EasyPoi是一个基于ApachePOI的开源Java工具库,旨在简化Excel和Word文档的操作,本文将详细介绍如何使用EasyPoi快速... 目录一、准备工作1、引入依赖二、准备好一个word模版文件三、编写导出方法的工具类四、在Export

Java+AI驱动实现PDF文件数据提取与解析

《Java+AI驱动实现PDF文件数据提取与解析》本文将和大家分享一套基于AI的体检报告智能评估方案,详细介绍从PDF上传、内容提取到AI分析、数据存储的全流程自动化实现方法,感兴趣的可以了解下... 目录一、核心流程:从上传到评估的完整链路二、第一步:解析 PDF,提取体检报告内容1. 引入依赖2. 封装

Python多线程实现大文件快速下载的代码实现

《Python多线程实现大文件快速下载的代码实现》在互联网时代,文件下载是日常操作之一,尤其是大文件,然而,网络条件不稳定或带宽有限时,下载速度会变得很慢,本文将介绍如何使用Python实现多线程下载... 目录引言一、多线程下载原理二、python实现多线程下载代码说明:三、实战案例四、注意事项五、总结引

C#使用Spire.XLS快速生成多表格Excel文件

《C#使用Spire.XLS快速生成多表格Excel文件》在日常开发中,我们经常需要将业务数据导出为结构清晰的Excel文件,本文将手把手教你使用Spire.XLS这个强大的.NET组件,只需几行C#... 目录一、Spire.XLS核心优势清单1.1 性能碾压:从3秒到0.5秒的质变1.2 批量操作的优雅

Mybatis-Plus 3.5.12 分页拦截器消失的问题及快速解决方法

《Mybatis-Plus3.5.12分页拦截器消失的问题及快速解决方法》作为Java开发者,我们都爱用Mybatis-Plus简化CRUD操作,尤其是它的分页功能,几行代码就能搞定复杂的分页查询... 目录一、问题场景:分页拦截器突然 “失踪”二、问题根源:依赖拆分惹的祸三、解决办法:添加扩展依赖四、分页

c++日志库log4cplus快速入门小结

《c++日志库log4cplus快速入门小结》文章浏览阅读1.1w次,点赞9次,收藏44次。本文介绍Log4cplus,一种适用于C++的线程安全日志记录API,提供灵活的日志管理和配置控制。文章涵盖... 目录简介日志等级配置文件使用关于初始化使用示例总结参考资料简介log4j 用于Java,log4c

使用Redis快速实现共享Session登录的详细步骤

《使用Redis快速实现共享Session登录的详细步骤》在Web开发中,Session通常用于存储用户的会话信息,允许用户在多个页面之间保持登录状态,Redis是一个开源的高性能键值数据库,广泛用于... 目录前言实现原理:步骤:使用Redis实现共享Session登录1. 引入Redis依赖2. 配置R

Spring AI使用tool Calling和MCP的示例详解

《SpringAI使用toolCalling和MCP的示例详解》SpringAI1.0.0.M6引入ToolCalling与MCP协议,提升AI与工具交互的扩展性与标准化,支持信息检索、行动执行等... 目录深入探索 Spring AI聊天接口示例Function CallingMCPSTDIOSSE结束语

三频BE12000国补到手2549元! ROG 魔盒Pro WIFI7电竞AI路由器上架

《三频BE12000国补到手2549元!ROG魔盒ProWIFI7电竞AI路由器上架》近日,华硕带来了ROG魔盒ProWIFI7电竞AI路由器(ROGSTRIXGR7Pro),目前新... 华硕推出了ROG 魔盒Pro WIFI7电竞AI路由器(ROG STRIX GR7 Phttp://www.cppcn

Linux如何快速检查服务器的硬件配置和性能指标

《Linux如何快速检查服务器的硬件配置和性能指标》在运维和开发工作中,我们经常需要快速检查Linux服务器的硬件配置和性能指标,本文将以CentOS为例,介绍如何通过命令行快速获取这些关键信息,... 目录引言一、查询CPU核心数编程(几C?)1. 使用 nproc(最简单)2. 使用 lscpu(详细信