diff --git a/build/fetch-sd-samplers.js b/build/fetch-sd-samplers.js new file mode 100644 index 0000000..bcd678c --- /dev/null +++ b/build/fetch-sd-samplers.js @@ -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') +})() diff --git a/data/sd-samplers.json b/data/sd-samplers.json new file mode 100644 index 0000000..b7f413c --- /dev/null +++ b/data/sd-samplers.json @@ -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" +} diff --git a/src/config.ts b/src/config.ts index ecec641..b2ef57e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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 export const horde = { k_lms: 'LMS',