koishijs / novelai-bot

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

增加一次生成多张图片的功能 #71

Closed LYAN0526 closed 1 year ago

LYAN0526 commented 1 year ago

Novelai官网的25刀订阅生成单张图片不需要点数,但是一次生成多张图片需要,但实际上一次生成多张图片和自己手动快速回车几次的效果(花费的时间)是一样的,可不可以利用机器人实现免费的一次生成多张图片呢? (使用排队生成最后收集起来一起发送回去的形式,或者挨个发送的形式?) 这样对于希望反复使用一个tag抽出最佳图片的用户来说很方便,同时又不需要点数,会是一个实用的功能。

MaikoTan commented 1 year ago

So my thought is like:

  1. Add an integer configuration named maxIteration.

    • Minimum value is 1.
    • If it set to 1, then would be nothing changed.
    • If it set to a more than 1 number, then there would be a new option iteration available.
  2. Add a new integer option named iteration

    • Minimum / default value is 1
    • Maximum value is maxIteration
    • If it is set to a number more then 1, then go to 3.
  3. Check the type of backend we are using, then choose

    • SD-WebUI: in the request body, set n_iter to iteration in 2.
    • NovelAI: request iteration times, cache the response
    • NAIFU: same as NovelAI or set n_samples to iteration in 2? (NEED HELP)
  4. Grab the responded images, then differ with

    • Ignore the output configuration: Construct a forward message and then send it.
    • Respect the output configuration: Send messages individually

Feel free to write your thoughts in comments.

cc @MirrorCY

MaikoTan commented 1 year ago

BTW, if we are trying to make them different backend to be behaved not so far, we should also set the seed incrementally if we request it several times.

MirrorCY commented 1 year ago

我不太确认各个后端的批量绘制实现有何不同,考虑到有可能不是所有人的显存都支持同步绘制多张图,而且顺序绘制并不太影响性能,不如直接统一为多次请求,减少代码量的同时也便于后续可能兼容的其他绘图后端?


I'm not sure how the batch drawing implementation of each backend is different. Considering that not everyone's video memory supports simultaneous drawing of multiple graphics, and sequential drawing does not affect the performance, it is better to unify it into multiple requests directly to reduce the amount of code and facilitate subsequent compatibility of other drawing backends.

shigma commented 1 year ago

我们已于 1.15.0 版本中实验性地实装了一次生成多张图片的功能。

目前可通过 --iterations 选项指定生成的轮数。配置项方面可以通过 maxIteration 设置最大的轮数。