GithubHelp home page GithubHelp logo

emetzodiac / nonebot_plugin_xcn-sdwebui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chening233/nonebot_plugin_xcn-sdwebui

0.0 0.0 0.0 632 KB

基于nonebot2的使用SD-Webui-API的跨平台画图机器人,面向小群自用,以及想将自己日用电脑显卡挂上来任群友摆弄的,该版本为不稳定测试版

License: MIT License

Python 100.00%

nonebot_plugin_xcn-sdwebui's Introduction

nonebot_plugin_xcn-sdwebui

banner

本插件基于nonebot2,支持QQ、飞书等平台的画图机器人,支持多SDWebUI的简单负载均衡

Feature

已实现功能

  • 简单FIFO队列进行多服务器负载均衡(不稳定)

  • #sd,查看当前所有服务器状态

  • #sd -ping,刷新服务器状态(连不上的将强制取消选中)

  • #sd -slt [服务器名称],选中某个服务器,不加名称全选所有服务器

  • #sddraw,接魔法、回复图片进行画图

  • #sdextra,图片放大

  • #sdtxt,修改文生图配置

  • #sdimg,修改图生图配置

  • #sdext,修改图片放大配置

  • #sdtagger,修改tagger插件配置

  • #sdinf,获取图片参数,#sdinf -tagger,额外调用tagger插件反推(自动卸载反推模型)

  • #sdskip,选中的服务器全部跳过一张,#sdskip -all,停止并清空所有任务

  • #sdfrev,重载模型进行显存释放,#sdfrev -all,全部进行重载模型

  • #sdlst model|vae|hires|extra|sampler|embed|lora|tagger,获取上述支持的列表

啊,唯独没有help指令 ψ(._. )>

待实现功能

  • 适配Telegram
  • 改善稳定性
  • 改善多服务器操作

关于魔法

#sddraw#sdtxt#sdimg#sdext等命令可接的参数,用于修改文生图或图生图等操作的参数

例子

支持“-”系列参数

#sddraw 1girl -cnt 6 -size 1024x768

上述指令将生成6张1024x768大小的二次元妹妹

支持“快速参数”(通常都是复制粘贴过来,非常方便)

1girl,solo,line up,retro art,medium breasts,cleavage,x hair ornaments,bare thighs,thighs gap,miniskirt,T-shirt,
Negative prompt: mutated hands,too many fingers,fused fingers,bad anatomy,malformed limbs,extra limbs,missing legs,deformed legs,extra legs,more than 2 knee,missing toes,bad proportions,deformed,mutation,morbid,duplicate,mutilated,(worst quality:1.4), (low quality:1.4), (monochrome:1.1), easynegative, bad-artist-anime, bad-image-v2-39000, bad_prompt_version2, bad_quality, ng_deepnegative_v1_75t, verybadimagenegative_v1.1-6400, vile_prompt3, bad-hands-5,
Steps: 30, Sampler: Euler a, CFG scale: 7.0, Seed: 1097555186, Size: 1024x768, Model hash: 5df765eff2, Model: donutholemix_v10, Denoising strength: 0.58, Clip skip: 2, Hires upscale: 2.0, Hires upscaler: Latent, Version: v1.3.0

当然也可以混合使用

实现

基于utils/param.py.ParameterOperation.txtimg_matcher

你可以找到并修改它使其按照你的意愿进行参数的匹配

单击此处跳转到匹配模式表

Usage

pip install requests
pip install requests_toolbelt
  1. 使用git clone克隆当前项目,并放到你的nonebot2机器人的src/plugins
  2. env.*中写好飞书的配置,仅对第一个飞书账号生效(在写了在写了
  3. pyproject.toml或其他地方配置加载该插件
  4. 修改插件目录里的config/config_webui.json中的servers字段,将你的SDWebUI填进去
  5. 启动后使用#sd#sd -ping测试是否正常连接到所有服务器

Problems and Defects

  1. 仅适配了QQ与飞书,Telegram以后再行适配
  2. 飞书需要自己注册并开放各种东西,有可能还要内网穿透,详见飞书文档以及nonebot2的飞书适配器文档
  3. 文生图时建议在Webui网页里把表格相关的选项全部关了,否则上传网格图片可能因图片过大上传失败

Magic matcher rules

以下是所有魔法的匹配规则,使用正则表达式,例如调整迭代步数:

#sddraw -steps 28#sdtxt -steps 28#sdimg -steps 28等等

你都可以在下面找到相应的匹配方法

txt_or_img = {
    "prompt": [r"(.*?)($|\n)"],
    "negative_prompt": [r"Negative prompt:(.*?)($|\n)", r"-ngt(.*?)($|\n)"],
    "steps": [r"Steps:(.*?)(,|$|\n)", r"-steps(.*?)(,|$|\n)"],
    "sampler_name": [r"Sampler:(.*?)(,|$|\n)", r"-sampler(.*?)(,|$|\n)"],
    "cfg_scale": [r"CFG scale:(.*?)(,|$|\n)", r"-cfg(.*?)(,|$|\n)"],
    "seed": [r"Seed:(.*?)(,|$|\n)", r"-seed(.*?)(,|$|\n)"],
    "width": [r"Size:(.*?)(,|$|\n)", r"-size(.*?)(,|$|\n)"],
    "height": [r"Size:(.*?)(,|$|\n)", r"-size(.*?)(,|$|\n)"],
    "n_iter": [r"-cnt(.*?)(,|$|\n)"],

    "enable_hr": [r"-hr(.*?)(,|$|\n)"],
    "denoising_strength": [
        r"Denoising strength:(.*?)(,|$|\n)",
        r"-ds(.*?)(,|$|\n)",
    ],
    "hr_scale": [r"Hires upscale:(.*?)(,|$|\n)", r"-upscale(.*?)(,|$|\n)"],
    "hr_upscaler": [r"Hires upscaler:(.*?)(,|$|\n)", r"-upscaler(.*?)(,|$|\n)"],
    "hr_second_pass_steps": [
        r"Hires steps:(.*?)(,|$|\n)",
        r"-hrsteps(.*?)(,|$|\n)",
    ],

    "sd_model_checkpoint": [r"Model:(.*?)(,|$|\n)", r"-model(.*?)(,|$|\n)"],
    "sd_vae": [r"-vae(.*?)(,|$|\n)"],
    "CLIP_stop_at_last_layers": [
        r"Clip skip:(.*?)(,|$|\n)",
        r"-clip(.*?)(,|$|\n)",
    ],
    "eta_noise_seed_delta": [r"ENSD:(.*?)(,|$|\n)", r"-ensd(.*?)(,|$|\n)"],
}

extra = {
    "gfpgan_visibility": [r"-gfp(.*?)(,|$|\n)"],
    "codeformer_visibility": [r"-codeformer(.*?)(,|$|\n)"],
    "codeformer_weight": [r"-codeformerw(.*?)(,|$|\n)"],
    "upscaling_resize": [r"-resize(.*?)(,|$|\n)"],
    "upscaling_crop": [r"-crop(.*?)(,|$|\n)"],
    "upscaling_resize_w": [r"-tosize(.*?)(,|$|\n)"],
    "upscaling_resize_h": [r"-tosize(.*?)(,|$|\n)"],
    "upscaler_1": [r"-upscaler1(.*?)(,|$|\n)"],
    "upscaler_2": [r"-upscaler2(.*?)(,|$|\n)"],
    "extras_upscaler_2_visibility": [r"-upscaler2w(.*?)(,|$|\n)"],
}

tagger = {
    "model": [r"-model(.*?)(,|$|\n)"],
    "threshold": [r"-threshold(.*?)(,|$|\n)"],
}

nonebot_plugin_xcn-sdwebui's People

Contributors

chening233 avatar

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.