Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 列出所有可用的Textual Inversion, Hypernetwork, Lora模型 #165

Open
Tracked by #143
yi03 opened this issue Feb 1, 2023 · 16 comments
Open
Tracked by #143
Labels
enhancement New feature or request help wanted Extra attention is needed stablediffusion related to Stable Diffusion backend

Comments

@yi03
Copy link

yi03 commented Feb 1, 2023

Scope

Stable Diffusion WebUI (AUTOMATIC1111)

Describe the problem related to the feature request

Textual Inversion, Hypernetwork, Lora这三种小模型在最新版的sd-webui里都可以在prompt里来选择模型,比如在prompt里输入<lora:amberGenshinImpact_flexibleV1:1>就表示选择了一个名叫amberGenshinImpact_flexibleV1Lora模型,权重是1。所以需要一个列出当前所有可用的Textual Inversion, Hypernetwork, Lora模型的功能。
这三种模型里我个人的话是Lora模型用的最多,有时会用Textual Inversion模型,几乎不用Hypernetwork模型。
其中选择Textual Inversion模型在prompt里不需要加<>,选择HypernetworkLora模型需要在prompt里加<>,而目前的bot会将<>转成&lt&gt,所以在选择HypernetworkLora模型之前需要先解决这个bug。相关讨论:#161

Describe the solution you'd like

向bot发送指令,bot列出所有可用的Textual Inversion, Hypernetwork, Lora模型。

Describe alternatives you've considered

No response

Additional context

No response

@MaikoTan MaikoTan added enhancement New feature or request help wanted Extra attention is needed labels Feb 1, 2023
@MaikoTan
Copy link
Member

MaikoTan commented Feb 1, 2023

Also note that the <lora:xxx> or whatever part SHOULD NOT be fed to the translator. So there're two ways to achieve this:

  1. maintain the a1111 way, we extract all <lora:xxx> out before the prompt being translating, and then append these extra net at the prompt end.

concern: is the order of extra nets affect the result? And how do we deal with embeddings which has not a special syntax?

  1. add new option to the command, like --extra lora:xxx,hypernet:yyy, and then we novelai-bot would just translate the prompt as always before adding extra nets for the user.

  2. Hybrid??


Feel free to comment out any thought you have! 🎉

@yi03
Copy link
Author

yi03 commented Feb 1, 2023

Also note that the <lora:xxx> or whatever part SHOULD NOT be fed to the translator. So there're two ways to achieve this:

  1. maintain the a1111 way, we extract all <lora:xxx> out before the prompt being translating, and then append these extra net at the prompt end.

concern: is the order of extra nets affect the result? And how do we deal with embeddings which has not a special syntax?

  1. add new option to the command, like --extra lora:xxx,hypernet:yyy, and then we novelai-bot would just translate the prompt as always before adding extra nets for the user.
  2. Hybrid??

Feel free to comment out any thought you have! 🎉

刚试了试,lora的顺序对结果有一点影响,不过大多时候影响不大。
image

考虑翻译的话,这两种我觉得都可以,看你们怎么方便吧。
不过如果方便的话,即使不对<lora:xxx>格式的翻译做特殊处理,也希望能不转义<>,因为这样的话,我这种平时不开翻译功能的人就可以直接复制sd-webui格式的prompt,不用再改写成--extra lora:xxx,hypernet:yyy的格式了。

@yi03
Copy link
Author

yi03 commented Feb 1, 2023

Textual Inversion的话,可能也可以设置成形如--extra ti:zzz的格式来避免翻译吧。

@MaikoTan
Copy link
Member

MaikoTan commented Feb 2, 2023

刚试了试,lora的顺序对结果有一点影响,不过大多时候影响不大。

Oh, I mean when you have a very long prompt, and there are extra networks everywhere, compares to a long prompt, but extra networks are all at the end. Would they behave different?

Par exemple : (let's say genshin-impact-amber here is an embedding)

A girl sitting under the tree, <lora:aaa>, on the grass, <lora:bbb>, <hypernet:ccc>, she has brown hair and closing eyes, smiling, genshin-impact-amber

compare to

A girl sitting under the tree, on the grass, she has brown hair and closing eyes, smiling, genshin-impact-amber, <lora:aaa>, <lora:bbb>, <hypernet:ccc>

Note: we would still maintain the relative position between extra networks, but put them at the end.

考虑翻译的话,这两种我觉得都可以,看你们怎么方便吧。 不过如果方便的话,即使不对<lora:xxx>格式的翻译做特殊处理,也希望能不转义<>,因为这样的话,我这种平时不开翻译功能的人就可以直接复制sd-webui格式的prompt,不用再改写成--extra lora:xxx,hypernet:yyy的格式了。

Yep, so personally I would like the hybrid mode, which would support these two ways both.

@MaikoTan
Copy link
Member

MaikoTan commented Feb 2, 2023

Also, webui call Textual Inversion as Embedding in some place, are they referring the same thing? Also Hypernetworks vs Hypernet.
Because I want to define a common / general but also short names for them.

@yi03
Copy link
Author

yi03 commented Feb 2, 2023

Textual Inversion, Aesthetic Gradients, Dream Artist 都是embedding(虽然后两个用的人比较少),用法也一样,所以确实--extra embedding:zzz这样可能更好,嫌太长的话可以缩写成--extra emb:zzz之类的。
HypernetworksHypernet 是同一个东西。

@MaikoTan
Copy link
Member

MaikoTan commented Feb 2, 2023

image

So this feature COULD be implementable with these APIs, but a weird thing is that the /sdapi/v1/embeddings API seems to return Textual Inversion only?

image

Also there is an API that returns all thumbnails for these extra networks.

@yi03
Copy link
Author

yi03 commented Feb 2, 2023

image

So this feature COULD be implementable with these APIs, but a weird thing is that the /sdapi/v1/embeddings API seems to return Textual Inversion only?

image

Also there is an API that returns all thumbnails for these extra networks.

这三种embedding的用法是一模一样的,只是训练的时候不一样。这三种embedding训练出来的pt文件也都放在同一个目录下,所以返回了Textual Inversion肯定也会返回另外两种,可能是文档没更新之类的吧。
缩略图我猜是这个东西
image

@MaikoTan
Copy link
Member

MaikoTan commented Feb 2, 2023

Okay, it looks like I put them different places so I have only Textual Inversion returned. Thanks for pointing out!

And I would not implement the thumbnails feature at least for now, maybe in the future, I don't know.

The last thing is, would you mind testing whether the order differences affects the result much? I mentioned it at #165 (comment)

@yi03
Copy link
Author

yi03 commented Feb 2, 2023

Okay, it looks like I put them different places so I have only Textual Inversion returned. Thanks for pointing out!

And I would not implement the thumbnails feature at least for now, maybe in the future, I don't know.

The last thing is, would you mind testing whether the order differences affects the result much? I mentioned it at #165 (comment)

我现在不太方便测试,大概今晚七点我会把测试结果发在这里。

@yi03
Copy link
Author

yi03 commented Feb 2, 2023

Okay, it looks like I put them different places so I have only Textual Inversion returned. Thanks for pointing out!

And I would not implement the thumbnails feature at least for now, maybe in the future, I don't know.

The last thing is, would you mind testing whether the order differences affects the result much? I mentioned it at #165 (comment)

image
image
试了试,似乎有一点区别,不过区别不大。

@MaikoTan
Copy link
Member

MaikoTan commented Feb 2, 2023

Okay, thanks for the testing.

I'll go with this way, and implement it as soon as possible.

@KotoriKoi
Copy link

KotoriKoi commented Feb 3, 2023

关于这个问题我想我可以给出一些建议,由于我不熟悉node.js和koishi,我在之前改写了另一个基于python和nonebot2的novelai-bot项目实现了这个issues的大部分功能要求。
image
首先关于ti(Textual Inversion),它分为正面ti 和负面ti,我使用了--pt和--ft,并且提供了简写-p和-f来调用它,之后只需要将它们分别添加到正面tag和负面tag即可,像这样:
image
image

由于ti的位置会影响图片的效果,而一般我用ti来定义某个角色,所以我把它放到了用户输入的tag前面,另外请注意ti不需要经过翻译。
如何列出ti?我试过了sdapi中的GET方法,但是它有弊端,当添加新的ti后需要刷新webui才能获取到新添加的ti(也可能是models,我不知道ti是不是也这样,另外目前sdapi中也没有lora的GET方法)。所以我传入了一个本地路径来获取它们,像这样:
image
image

这是功能展示:
image
image

然后是lora,目前来说我还没有看到负面lora(但实际上它可以放到反向提示词,并且你正反都放入同一个lora权重都是1它们会抵消),另外它的位置不会影响效果,效果取决于权重,但我喜欢把它放到最前面。我仍然使用传入路径的方法获取它们,然后定义一些命令来调用它,像这样:
image
image
image
image

其中列出lora的方法和ti的方法一样。
最后是Hypernetwork,我不太使用它,但它和以上用的的方法差不多。
然后是关于该issues没有提到的一个功能,像这样:
image
image

实现它只需要在post中加入styles即可,具体可以参考sdapi
image
image

希望这可以给你帮助。

@MaikoTan
Copy link
Member

MaikoTan commented Feb 3, 2023

Thanks for the sharing and explanation!
I'll take a look and try to implement this as soon as possible.

@yi03
Copy link
Author

yi03 commented Feb 11, 2023

Okay, thanks for the testing.

I'll go with this way, and implement it as soon as possible.

今天又想到了个feature,就是不知道放不方便加个备注功能。因为很多lora的名字都很长,lora模型的名字也经常是某个角色的英文名,看不懂是啥意思,就想加个备注。
比如说列的时候备注名和原名都列出来,调用的时候可以直接加--extra lora:备注名来调用。

@yi03
Copy link
Author

yi03 commented Feb 22, 2023

Okay, thanks for the testing.
I'll go with this way, and implement it as soon as possible.

今天又想到了个feature,就是不知道放不方便加个备注功能。因为很多lora的名字都很长,lora模型的名字也经常是某个角色的英文名,看不懂是啥意思,就想加个备注。 比如说列的时候备注名和原名都列出来,调用的时候可以直接加--extra lora:备注名来调用。

我啥比了当我没说,我忘记可以本地改lora文件名了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed stablediffusion related to Stable Diffusion backend
Projects
None yet
Development

No branches or pull requests

3 participants