Code Monkey home page Code Monkey logo

stable-journey-bot's Introduction

Stable Journey Bot

Discord bot client for AUTOMATIC1111's stable-diffusion-webui.

image

機能

  • Prompt Style のサポート
  • プロンプトプリセット
  • ネガティブプロンプト
  • サンプラーの選択
  • モデルの切り替え
  • 複数枚生成
  • リローリング
  • highres fix

使い方

プロジェクトのクローン

レポを落として、ルートに移動します。

git clone https://github.com/p1atdev/stable-journey-bot.git
cd stable-journey-bot

Web UIの準備

必要に合わせて起動フラグに以下を追加します

  • --api 必須。API機能を有効にします
  • --listen 欲しい場合のみ。0.0.0.0 でホストされるので、ドメインと紐づけている人とかはこれが必要。ただし、これを有効にすると拡張機能を入れることが出来ないので、頻繁に拡張機能を弄る人は非推奨。
  • --nowebui 推奨。Gradio の Web UI 機能を無効にします。Bot から生成するだけなら Web UI は不要なので、これを有効にすると起動が早くなったりする気がします。多分。
  • --share Botを自分のPC以外で動かしたいときには必須。ただし --nowebui とは共存できません。
  • --ngrok Gradio の share を利用しないときの選択肢。詳しい使い方知らないのでわからない。

また、起動時に出る Running on local URL: http://0.0.0.0:7860Uvicorn running on http://0.0.0.0:7861 はちゃんと見ておきましょう。特にポート番号。基本的に localhost:7860 ですが、 --nowebui の場合は 7861 になります。

./webui-user.bat の設定例

ローカルで軽く動かすとき

@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--xformers --api --nowebui
set ATTN_PRECISION=

call webui.bat

--xformers などはお好みで指定してください。

外部に公開するとき

@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--xformers --api --share
set ATTN_PRECISION=

call webui.bat

BOT の設定

config.example.yaml をコピー&リネームして config.yaml を作成します。

例に従って必要な項目を入力します。

# Discord
DISCORD_TOKEN: hogehoge
GUILD_ID: "1234567890"

# BOT
globalCommands: false
allows:
  - switch
  - refresh
  - imagine
  - info
  - status
  # - neko

defaultParameters:
  style: ""
  sampler: "DPM++ 2M Karras"
  width: 512
  height: 768
  highresFix: false 
  clipSkip: 2 

additionalParameters:
  promptPrefix: "masterpiece, exceptional"
  promptSuffix: "ultra detailed"
  negativePromptPrefix: "NSFW, badquality, bad anatomy"
  negativePromptSuffix: ""

serverType: "AUTOMATIC1111"

# API server address
host: http://localhost:7860
  • DISCORD_TOKEN: BOTのトークン

  • GUILD_ID: BOTを動かすサーバー

  • globalCommands: グローバルでスラッシュコマンドを有効にするかどうか

  • allows: 実行を許可するコマンド名

  • defaultParameters: デフォルトのパラメーター。 /imagine で指定されない場合は、この値が使われる。

    • style: デフォルトで使用する Prompt Style の名前
    • widht: 幅
    • height: 高さ
    • highresFix: highres fix を有効にする
    • ckipSkip: CLIP skip の値を変更する
  • additionalParameters:

    • promptPrefix: 常に prompt の先頭に追加する内容
    • promptSuffix: 常に prompt の後ろに追加する内容
    • negativePromptPrefix: 常に negative prompt の先頭に追加する内容
    • negativePromptSuffix: 常に negative prompt の後ろに追加する内容
  • serverType: 現状は常に AUTOMATIC1111。いつかほかのに対応するかも?しないかも?

  • host: Web UI のアドレス

実行

deno task start

で実行します。Ctrl + C で停止です。

実行 (docker compose)

docker compose up

コマンド一覧

/switch

モデルを切り替えます。

image

  • name: モデル名 (必須)

/refresh

モデルなどをリフレッシュします。

Stable-diffusion ディレクトリにモデルを追加したり削除した場合は、これを実行しないとモデルを切り替えることが出来ません。

/imagine

生成します。

image

  • prompt: ポジティブプロンプト (必須)
  • negative: ネガティブプロンプト
  • prompt-style: プロンプトスタイル。入力されたプロンプトの先頭に挿入されます。
  • width: 幅。512, 768, ~ 2048 まででキリがいいものを入れてます。
  • height: 高さ。width 同様
  • seed: シード値
  • sampler: サンプラー
  • steps: ステップ数
  • scale: CFG scale
  • highres-fix: highres fix を有効にします
  • clip-skip: CLIP skip を変更します
  • count: 生成枚数。最大は 4。

TODO

  • /imagine のデフォルト値の設定
  • アスペクト比や生成枚数をカスタマイズできるように
  • 生成したものの削除
  • エラーハンドリング
  • リローリング、バリエーション (midjourney風に)
  • img2img
  • Lsmith?

stable-journey-bot's People

Contributors

p1atdev avatar slashnephy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

stable-journey-bot's Issues

ckg model to much?

Task start deno run -A main.ts
[INFO] Commands: [ "imagine", "switch", "info", "status", "refresh" ]
[INFO] Registered handling interactions
[INFO] Registering commands globally
[ERROR] Error occurred when setting up bot: Error: [400] The options was improperly formatted, or the server couldn't understand it.
{"code":50035,"errors":{"0":{"options":{"2":{"choices":{"_errors":[{"code":"BASE_TYPE_MAX_LENGTH","message":"Must be 25 or fewer in length."}]}}}}},"message":"Invalid Form Body"}
at Object.runMethod (https://deno.land/x/[email protected]/rest/runMethod.ts:30:9)
at upsertGlobalApplicationCommands (https://deno.land/x/[email protected]/helpers/interactions/commands/upsertGlobalApplicationCommands.ts:24:34)
at Object.converted. [as upsertGlobalApplicationCommands] (https://deno.land/x/[email protected]/bot.ts:402:7)
at registerCommands (file:///C:/stable-journey-bot/commands.ts:46:27)
at refreshCommands (file:///C:/stable-journey-bot/utils.ts:32:19)
at async StableJourneyBot.setup (file:///C:/stable-journey-bot/bot.ts:21:13)
at async StableJourneyBot.start (file:///C:/stable-journey-bot/bot.ts:34:9)
at async file:///C:/stable-journey-bot/main.ts:8:1
[ERROR] Please check your config file or server status and try again!

feature: clip, more resolutions and hiRes?

First of all, thanks for the great work, overall this bot is the best bot in github for SD

Any plans to add support for clip, more resolutions and hiRes?
Since some model has better quality for specific clip, it would be helpful to add tweaks for clip, the command string for clip in sd is CLIP_stop_at_last_layers
More resolutions can support more content customization, since some model's composition will change depending on the resolution

The Authorization token you passed did not have permission

PS D:\stable-journey-bot> deno task start
Task start deno run -A main.ts
[SUCCESS] Successfully connected to gateway
error: Uncaught (in promise) Error: [403] The Authorization token you passed did not have permission to the resource.
{"message":"Missing Access","code":50001}
  Error.captureStackTrace(errorStack);
        ^
    at Object.runMethod (https://deno.land/x/[email protected]/rest/runMethod.ts:30:9)
    at getGuildApplicationCommands (https://deno.land/x/[email protected]/helpers/interactions/commands/getGuildApplicationCommands.ts:20:34)
    at Object.converted.<computed> [as getGuildApplicationCommands] (https://deno.land/x/[email protected]/bot.ts:401:7)
    at registerCommands (file:///D:/stable-journey-bot/command.ts:143:29)
    at StableJourneyBot.refreshCommands (file:///D:/stable-journey-bot/bot.ts:50:15)
    at async Object.bot.events.ready (file:///D:/stable-journey-bot/bot.ts:62:13)

I already give bot a adminisitor permission and another SD discord bot can work with same token

register imagine error

Error occurred when setting up bot: Error: [400] The options was improperly formatted, or the server couldn't understand it.
{"code":50035,"errors":{"0":{"options":{"2":{"choices":{"_errors":[{"code":"BASE_TYPE_MAX_LENGTH","message":"Must be 25 or fewer in length."}]}}}}},"message":"Invalid Form Body"}
at Object.runMethod (https://deno.land/x/[email protected]/rest/runMethod.ts:30:9)
at upsertGuildApplicationCommands (https://deno.land/x/[email protected]/helpers/interactions/commands/upsertGuildApplicationCommands.ts:26:34)
at Object.converted. [as upsertGuildApplicationCommands] (https://deno.land/x/[email protected]/bot.ts:402:7)
at registerCommands (file:///D:/stable-journey-bot-master/commands.ts:53:31)
at refreshCommands (file:///D:/stable-journey-bot-master/utils.ts:32:19)
at async StableJourneyBot.setup (file:///D:/stable-journey-bot-master/bot.ts:21:13)
at async StableJourneyBot.start (file:///D:/stable-journey-bot-master/bot.ts:34:9)
at async file:///D:/stable-journey-bot-master/main.ts:8:1
[ERROR] Please check your config file or server status and try again!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.