koishijs / novelai-bot

Generate images by NovelAI | 基于 NovelAI 的画图机器人
https://bot.novelai.dev
MIT License
2.48k stars 204 forks source link

Bug: 启用hiresFix后图片输出错误 #158

Closed KotoriKoi closed 1 year ago

KotoriKoi commented 1 year ago

Describe the bug

本地部署的sd-webui启用hiresFix后图片输出错误,请参考Screenshots中的截图,Koish后台日志一切正常,只有聊天内容不方便展示。通过webui的控制台发现启用hiresFix后输出图像的速度没有太大变换(甚至感觉变快了),这不符合逻辑。

Steps to reproduce

参数 启用hiresFix后会重现该现象,我不知道其它参数是否有影响,具体参数参考截图,可能的原因是启用hiresFix后超过了图片最大尺寸,但实际测试拉到足够的最大尺寸仍然会重现该现象。

Expected behavior

无法启用hiresFix会导致图像质量偏低,希望能够给出解决方案。

Screenshots

2_SR(PASZ{4ROQ4QW$VV9TH

Relevant log output

No response

Launcher

Koishi Desktop

Backend

Stable Diffusion WebUI (AUTOMATIC1111)

Versions

Additional context

No response

MaikoTan commented 1 year ago

Please provide your webui commit SHA here also. I cannot reproduce this issue on my side currently.

請在此處提供您的 webui 提交 SHA。 我目前無法在我側重現此問題。

UPDATE: En plus, what is your model and parameters during the generation? Is it possible to share your config and prompt?

更新:而且,係生成中你的模型同參數是什麼?好唔好分享下你的配置同埋提示文?

MaikoTan commented 1 year ago

Also, the hires fix feature is actually fix the problem that when you are generating large image like more than 1024*1024, there might be multiple characters or entities that are not what you want. So when you enable the hires fix feature, it would firstly generate a smaller image and then use i2i to enlarge it to the requested resolution. So I don't know that you would get lower quality images without the hires fix flag.

See https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#hires-fix

另外,hires fix 功能實際上解決了當您生成類似超過 1024*1024 的大圖像時,可能會有多個字符或實體不是您想要的問題。 因此,當您啟用 hires fix 功能時,它會先生成較小的圖像,然後使用 i2i 將其放大到要求的分辨率。 所以我不知道如果沒有 hires fix 標誌,您會得到質量較低的圖像。

https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#hires-fix

KotoriKoi commented 1 year ago

sc 我使用SHA为d8f8bcb8的webui,模型为AbyssOrangeMix2_sfw,你可以在huggingface得到它。但实际上更新到最新SHA的webui并切换其它模型仍然会出现该问题。为排除其它东西干扰,我已将插件重置,仅启用了hiresFix,提示词仅使用girl。我生成了两张图片作为区别,如截图中所示,在生成第二张图片执行与第一张图片相同step后异常终止。 显卡为3070,显存8G,在web端使用相同参数和提示文能够正常生成。另外能否添加webui中的hireFix的相关参数到配置项以及支持LoRA?谢谢!

KotoriKoi commented 1 year ago

api vs @MaikoTan 我已经知道了原因,sd-webui的api中denoising_strength默认为0导致的问题,我在nonebot的novelai插件中用图二的post参数测试hiresfix一切正常,我想你可以把这些参数添加到koishi配置项。

MaikoTan commented 1 year ago

Yep, I also found that this commit changes the behaviour of hires fix feature, and after that AUTOMATIC1111 added another commit that allows you to use the old hires fix again. Maybe it causes the problem, but I am not very sure.

MaikoTan commented 1 year ago

Also notice here, the hires fix feature was changed since the commit that is mentioned above, now the first part would use the width and height directly from API payloads, and then enlarge it by multiplying a constant (default is 2).

So in the future, we should change type of the hiresFix as a number to carry the enlargement multipliers.

還要注意這裡,'hires fix' 特性在上面提到的 commit 後發生了變化,現在第一部分將直接從 API 有效載荷中使用 widthheight,然後通過乘以一個常量(默認是 2).

所以在未來,我們應該將 hiresFix 的類型更改為一個數字來攜帶放大倍數。

MaikoTan commented 1 year ago

Par exemple, the current behaviour is like: when you using nai -r 512x512 -H girl, you're getting an image in 1024*1024 instead of the original 512*512.

例如,當前的行為是這樣的: 當您使用 nai -r 512x512 -H girl 時,您將獲得 10241024 格式的圖像,而不是原始的 512512 圖像。