mirror of
https://github.com/koishijs/novelai-bot
synced 2025-01-07 07:06:54 +08:00
refa: auto generate sd samplers from api (#232)
This commit is contained in:
parent
179b41bd1e
commit
2540cdca9e
26
build/fetch-sd-samplers.js
Normal file
26
build/fetch-sd-samplers.js
Normal file
@ -0,0 +1,26 @@
|
||||
const fsp = require('fs/promises')
|
||||
const http = require('http')
|
||||
const path = require('path')
|
||||
|
||||
const API_ROOT = process.argv[2] || 'http://localhost:7860'
|
||||
const SAMPLERS_ENDPOINT = '/sdapi/v1/samplers'
|
||||
const DATA_JSON_PATH = path.join(__dirname, '..', 'data', 'sd-samplers.json')
|
||||
|
||||
;(async () => {
|
||||
const r = await new Promise((resolve, reject) => {
|
||||
http.get(API_ROOT + SAMPLERS_ENDPOINT, res => {
|
||||
let data = ''
|
||||
res.on('data', chunk => data += chunk)
|
||||
res.on('end', () => resolve(JSON.parse(data)))
|
||||
}).on('error', reject)
|
||||
})
|
||||
|
||||
const samplers = r.reduce((acc, sampler) => {
|
||||
const { name, aliases, options } = sampler
|
||||
acc[aliases[0]] = name
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
const json = JSON.stringify(samplers, null, 2)
|
||||
await fsp.writeFile(DATA_JSON_PATH, json + '\n')
|
||||
})()
|
31
data/sd-samplers.json
Normal file
31
data/sd-samplers.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"k_dpmpp_2m_ka": "DPM++ 2M Karras",
|
||||
"k_dpmpp_sde_ka": "DPM++ SDE Karras",
|
||||
"k_dpmpp_2m_sde_exp": "DPM++ 2M SDE Exponential",
|
||||
"k_dpmpp_2m_sde_ka": "DPM++ 2M SDE",
|
||||
"k_euler_a": "Euler a",
|
||||
"k_euler": "Euler",
|
||||
"k_lms": "LMS",
|
||||
"k_heun": "Heun",
|
||||
"k_dpm_2": "DPM2",
|
||||
"k_dpm_2_a": "DPM2 a",
|
||||
"k_dpmpp_2s_a": "DPM++ 2S a",
|
||||
"k_dpmpp_2m": "DPM++ 2M",
|
||||
"k_dpmpp_sde": "DPM++ SDE",
|
||||
"k_dpmpp_2m_sde_heun": "DPM++ 2M SDE Heun",
|
||||
"k_dpmpp_2m_sde_heun_ka": "DPM++ 2M SDE Heun Karras",
|
||||
"k_dpmpp_2m_sde_heun_exp": "DPM++ 2M SDE Heun Exponential",
|
||||
"k_dpmpp_3m_sde": "DPM++ 3M SDE",
|
||||
"k_dpmpp_3m_sde_ka": "DPM++ 3M SDE Karras",
|
||||
"k_dpmpp_3m_sde_exp": "DPM++ 3M SDE Exponential",
|
||||
"k_dpm_fast": "DPM fast",
|
||||
"k_dpm_ad": "DPM adaptive",
|
||||
"k_lms_ka": "LMS Karras",
|
||||
"k_dpm_2_ka": "DPM2 Karras",
|
||||
"k_dpm_2_a_ka": "DPM2 a Karras",
|
||||
"k_dpmpp_2s_a_ka": "DPM++ 2S a Karras",
|
||||
"restart": "Restart",
|
||||
"ddim": "DDIM",
|
||||
"plms": "PLMS",
|
||||
"unipc": "UniPC"
|
||||
}
|
@ -53,39 +53,8 @@ export namespace sampler {
|
||||
}
|
||||
|
||||
// samplers in stable-diffusion-webui
|
||||
// https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/sd_samplers_compvis.py#L12
|
||||
// https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/sd_samplers_kdiffusion.py#L12
|
||||
export const sd = {
|
||||
k_dpmpp_2m_ka: 'DPM++ 2M Karras',
|
||||
k_dpmpp_sde_ka: 'DPM++ SDE Karras',
|
||||
k_dpmpp_2m_sde_exp: 'DPM++ 2M SDE Exponential',
|
||||
k_dpmpp_2m_sde_ka: 'DPM++ 2M SDE',
|
||||
k_euler_a: 'Euler a',
|
||||
k_euler: 'Euler',
|
||||
k_lms: 'LMS',
|
||||
k_heun: 'Heun',
|
||||
k_dpm_2: 'DPM2',
|
||||
k_dpm_2_a: 'DPM2 a',
|
||||
k_dpmpp_2s_a: 'DPM++ 2S a',
|
||||
k_dpmpp_2m: 'DPM++ 2M',
|
||||
k_dpmpp_sde: 'DPM++ SDE',
|
||||
k_dpmpp_2m_sde_heun: 'DPM++ 2M SDE Heun',
|
||||
k_dpmpp_2m_sde_heun_ka: 'DPM++ 2M SDE Heun Karras',
|
||||
k_dpmpp_2m_sde_heun_exp: 'DPM++ 2M SDE Heun Exponential',
|
||||
k_dpmpp_3m_sde: 'DPM++ 3M SDE',
|
||||
k_dpmpp_3m_sde_ka: 'DPM++ 3M SDE Karras',
|
||||
k_dpmpp_3m_sde_exp: 'DPM++ 3M SDE Exponential',
|
||||
k_dpm_fast: 'DPM fast',
|
||||
k_dpm_ad: 'DPM adaptive',
|
||||
k_lms_ka: 'LMS Karras',
|
||||
k_dpm_2_ka: 'DPM2 Karras',
|
||||
k_dpm_2_a_ka: 'DPM2 a Karras',
|
||||
k_dpmpp_2s_a_ka: 'DPM++ 2S a Karras',
|
||||
restart: 'Restart',
|
||||
ddim: 'DDIM',
|
||||
plms: 'PLMS',
|
||||
unipc: 'UniPC',
|
||||
}
|
||||
// auto-generated by `build/fetch-sd-samplers.js`
|
||||
export const sd = require('../data/sd-samplers.json') as Dict<string>
|
||||
|
||||
export const horde = {
|
||||
k_lms: 'LMS',
|
||||
|
Loading…
Reference in New Issue
Block a user