探索 StableDiffusion:生成高质量图片学习及应用(中)

简介: 探索 StableDiffusion:生成高质量图片学习及应用(中)

更多精彩内容,欢迎观看:

探索 StableDiffusion:生成高质量图片学习及应用(上):

https://developer.aliyun.com/article/1263239?groupCode=taobaotech


  • 一些参考prompt


negtive提示符:


ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face

((((ugly)))), (((duplicate))), ((morbid)), ((mutilated)), [out of frame], extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), out of frame, ugly, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck)))


  1. 1 如何想出好的prompt:https://stable-diffusion-art.com/how-to-come-up-with-good-prompts-for-ai-image-generation/#Some_good_keywords_for_you
  2. 2负面提示符:https://stable-diffusion-art.com/how-to-use-negative-prompts/#Negative_prompt_with_Stable_Diffusion_v15


 生成高质量的图片进阶?


  • 图片修复 (inpaiting)


https://stable-diffusion-art.com/inpainting-remove-extra-limbs/

  1. 1 下载inpaiting模型;
  2. 2 可以生成图片后点击send img2img,也可以自己上传到img2img;
  3. 3 用刷子进行绘制想要修改的区域,刷完之后,重新生成。


其中的一些参数:


模型记得选择SDv1.5修复模型(sd-v1-5-inpainting.ckpt)。


  • 训练自己的模型?


可以直接在Colab云端训练,本地也不用配置环境,训练也很快:

https://colab.research.google.com/github/Linaqruf/kohya-trainer/blob/main/kohya-LoRA-dreambooth.ipynb#scrollTo=WNn0g1pnHfk5


想在本地训练:

  1. 参考:https://github.com/bmaltais/kohya_ss
  2. 训练教程:https://stable-diffusion-art.com/dreambooth/


  1. 1 确定要训练模型的唯一标识(起个名字),以及这个模型所对应的类型(class);
比如如果想要训练一个狗的模型,那么狗就是对应的类型(class),然后可以给这个狗起一个名字。名字尽量不要太容易重复;
  1. 2 准备把图片制作有有固定尺寸,创建一个目录:_一次可以训练多个概念
  2. 3 开始训练、选择在colab上训练是最方便的方式,本地就省去了很多配置。
    以上要准备的内容简单说就是:图片、类型、唯一名字
    https://colab.research.google.com/github/Linaqruf/kohya-trainer/blob/main/kohya-LoRA-dreambooth.ipynb#scrollTo=kh7CeDqK4l3Y


按照colab正常操作就行;最终会输出一份训练的模型到你的Google Driver中。然后自己在本地测试:

prompt:a woman, hitokomoru , with a cat on her head  

negtive: (worst quality:2), (low quality:2),disfigured, ugly, old, wrong finger


使用自己的Lora VS  不使用Lora

还有一次可以训练多个概念,把文件件组织好就行了


  • 图片编辑 pix2pix


编辑配置文件configs/instruct-pix2pix.yaml,改为如下内容:



use_ema: true   // 默认为false    load_ema: true


denoising 改为1.0, 抽样使用Euler a算法;

常用参数:

  1. 1 text cfg: 越大代表生成的内容越接近我们的文字描述
  2. 2 image cfg:  越大代表越接近我们的原始图片,越小代表可以越不按照原始图片生成


下面是一些常用的指令模板:

  1. Change the Style to (an artist or style name)
  2. Have her/him (doing something)
  3. Make her/him look like (an object or person)
  4. Turn the (something in the photo) into a (new object)
  5. Add a (object)
  6. Add a (object) on (something in the photo)
  7. Replace the (object) with (another object)
  8. Put them in (a scene or background)
  9. Make it (a place, background or weather)
  10. Apply (a emotion or something on a person)


有时候重新表达指令可以改善结果(例如,“turn him into a dog”与“make him a dog”与“as a dog”)。 增加 steps 的值有时可以改善结果。 人脸看起来奇怪? Stable Diffusion自编码器在图像中人脸较小的情况下会有问题。尝试:裁剪图像,使人脸在画面中占据更大的部分。


资料地址:

  1. 模型下载地址:https://huggingface.co/timbrooks/instruct-pix2pix/resolve/main/instruct-pix2pix-00-22000.ckpt
  2. 线上体验地址:https://huggingface.co/spaces/timbrooks/instruct-pix2pix


  • 使用脚本


Stable Diffusion的webUI中默认有一些脚本,可以方便我们尝试一些不同的生成方式。

  • 常见生成人物问题与处理


 StableDiffusion生成图片演示


  • 水底美女文字生成 text2img


水下摄影肖像,iu1,裙子,美丽的详细女孩,极其详细的眼睛和脸,美丽的详细眼睛,闭着嘴,黑色的头发,锁骨,裸露的肩膀,长睫毛,飘逸的头发,气泡,阳光穿过水面,逼真,照片般的真实感,由泰德·格兰博拍摄,最高品质。

正面提示:underwater photography portrait,  iu1, dress, beautiful detailed girl, extremely detailed eyes and face, beautiful detailed eyes, closed mouth, black hair, collarbone, bare shoulders, longeyelashes, floating hair,  bubbles,  sun light breaking through water surface, realistic, photorealistic, by ted grambeau, best quality


反面提示:(worst quality:2), (low quality:2), (normal quality:2) , goggles, sun glasses, hand, extra fingers, fewer fingers, strange fingers, bad hand



参数

参数说明

CFG scale

8

值越大,越符合你的prompt,范围为1~30;默认为7.


个人测试:

5以下看起来不好看

Sampling steps

20

理论上越大,图片质量越高,但是可能会带来模糊

Image size

512×512


Seed

-1

Face restoration

Codeformer

勾选面部修复

Sampling method

DPM++ 2M Karas


Model

F222

默认是SD模型,可以下载这个模型,F222主要用在女性身材生成上比较擅长:

https://huggingface.co/acheong08/f222/blob/main/f222.ckpt

微调模型

Lora iu

https://civitai.com/models/11722/iu

默认是SD模型,可以下载这个模型,F222主要用在女性身材生成上比较擅长:

https://huggingface.co/acheong08/f222/blob/main/f222.ckt


我做的事情:

  1. 1 下载并使用F222模型;
  2. 2 参考其他水底美女提示符,修改人物生成要用的人物;
  3. 3 微调提示符,多次生成;


  • 西湖风景后期处理 img2img


原始照片:

生成prompt:

第一张prompt: ((Sunset)) , (Lake  Gold) , Boat Center, Mountain, Tree in left, realistic, photorealistic, , 8K,Wide-angle, (expansive:1.5) , a combination of red, orange, pink, and purple.

negtive: (worst quality:2), (low quality:2)


第二张:a sunset over a body of water with a tree branch hanging over it and the sun reflecting in the water, a photo, Arthur Pan, dau-al-set, tranquil


第三张:two ducks swimming in a pond with fish in the water and a fish in the water behind them,, an impressionist painting, Emperor Huizong of Song, cloisonnism, tone mapping


第四张:a field of colorful flowers with green stems and yellow and red flowers in the middle of the field,, a jigsaw puzzle, Bob Thompson, color field, rich vivid colors



  • 人像卡通化测试 img2img


prompt:a young man holding a durian fruit in his hand , portrait ,detailed eyes, hyperrealistic

negtive prompt:  (worst quality:2), (low quality:2),disfigured, ugly, old

模型:AnythingV3;


Denoising strength从0.1依次升高,第一张为原图;


Denoising strength: 0.4~0.7(可以看到从0.5的噪声强度开始,AI已经开始自由发挥了,虽然也会参考原图)

Denoising strength: 0.8~0.9 (基本完全自由发挥)


依旧是上个原图,换为midjourney v4模型,Denoising strength测试0.2, 0.4, 0.6, 0.8相同的提示词,换个模型之后整体风格大变;

  • 图片编辑测试  pix2pix


TextCFG固定:7.5,调整ImageCFG;


Put him in beach



  • 控制人物姿势 ControlNet


提示:A girl, showing her muscles, detailed face , realistic ,8k  

negtive prompht: (worst quality:2), (low quality:2),disfigured, ugly, old,nsfw


除了控制姿势,还可以控制人物的表情,这里我们只是控制人物的姿势;


  • 图片Inpaiting测试  img2img



给“模特”戴项链:


A girl, (necklace:1.5), showing her muscles, detailed face , realistic ,8k  


给“模特”戴墨镜:

A girl, (sunglasses:1.5), showing her muscles, detailed face , realistic ,8k  


更多精彩内容,欢迎观看:

探索 StableDiffusion:生成高质量图片学习及应用(下):

https://developer.aliyun.com/article/1263237?groupCode=taobaotech




相关文章
|
人工智能 编解码 C++
AI 绘画Stable Diffusion 研究(二)sd模型ControlNet1.1 介绍与安装(1)
AI 绘画Stable Diffusion 研究(二)sd模型ControlNet1.1 介绍与安装
596 0
|
Web App开发 编解码 算法
发现一个非常好用的RTC(实时音视频通信)方案,做直播和视频通话都很牛
HaaS RTC是阿里云IoT联合视频云开发的IoT设备端上的实时通讯服务,主要面向直播,音视频通话等各种场景。
3193 20
发现一个非常好用的RTC(实时音视频通信)方案,做直播和视频通话都很牛
|
5月前
|
人工智能 自然语言处理 运维
起飞啦,太easy啦!!!小白的神级AI辅助工具,一句话即可搭建超50个节点的工作流~~~~
n8n-MCP是专为n8n打造的AI智能中间件,让大模型“读懂”节点与属性,通过自然语言自动生成复杂工作流。支持541个节点、2700+模板,兼容Claude、Cursor等AI工具,显著降低自动化门槛,提升构建效率,助力技术与非技术人员高效协作。
574 0
|
并行计算 PyTorch Shell
YOLOv11改进策略【Neck】| 有效且轻量的动态上采样算子:DySample
YOLOv11改进策略【Neck】| 有效且轻量的动态上采样算子:DySample
1336 11
YOLOv11改进策略【Neck】| 有效且轻量的动态上采样算子:DySample
|
小程序 开发者
【微信小程序开发实战项目】——如何制作一个属于自己的花店微信小程序(1)
👀 探索鲜花电商小程序,提供全球鲜花选购,一键配送,打造无缝购花体验。🌹 💻 示例代码展示`app.json`配置文件和首页`index.wxml`、`index.wxss`、`index.js`,包含轮播图、导航栏及商品推荐布局。🛠️ 📖 查看[微信小程序开发](https://blog.csdn.net/2301_77628600?spm=1011.2266.3001.5343)专栏,获取更多教程。📖 🎉 持续更新中,点赞👍、收藏⭐、留言📝,一起学习进步!🚀
517 1
【微信小程序开发实战项目】——如何制作一个属于自己的花店微信小程序(1)
|
人工智能 Linux 开发工具
Linux安装Taiyi stable-diffusion-webui
Linux安装Taiyi stable-diffusion-webui
|
算法 物联网
探索 StableDiffusion:生成高质量图片学习及应用(上)
探索 StableDiffusion:生成高质量图片学习及应用(上)
1283 0
|
算法 数据处理 vr&ar
GaussianObject用4张照片生成高质量3D物体
【2月更文挑战第17天】GaussianObject用4张照片生成高质量3D物体
460 2
GaussianObject用4张照片生成高质量3D物体
|
数据采集 机器学习/深度学习 数据挖掘
Python数据清洗与预处理面试题解析
【4月更文挑战第17天】本文介绍了Python数据清洗与预处理在面试中的常见问题,包括Pandas基础操作、异常值处理和特征工程。通过示例代码展示了数据读取、筛选、合并、分组统计、离群点检测、缺失值和重复值处理、特征缩放、编码、转换和降维。强调了易错点,如忽视数据质量检查、盲目处理数据、数据隐私保护、过度简化特征关系和忽视模型输入要求。掌握这些技能和策略将有助于在面试中脱颖而出。
752 8
|
自然语言处理 数据可视化 机器人
如何画一个词云 | python小知识
词云,又称文字云,是文本数据的视觉表示,通过将网络文本或大量文本数据中出现频率较高的“关键词”以不同大小的字体、颜色或形状进行可视化展示,形成类似云的彩色图形。这种视觉上的突出使得浏览者能够一眼扫过文本就领略到文本的主旨,是数据可视化的一种重要形式 【7月更文挑战第6天】
738 0

热门文章

最新文章