Skip to content

Commit

Permalink
refactor: extract karras scheduler from sampler in ai horde
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan committed Feb 15, 2024
1 parent dcfda09 commit 061a87b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
15 changes: 3 additions & 12 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export namespace sampler {
'unipc': 'UniPC',
}

// samplers in AI horde
// https://stablehorde.net/api/
// (under Models - ModelGenerationInputStable - sampler_name)
export const horde = {
k_lms: 'LMS',
k_heun: 'Heun',
Expand All @@ -93,18 +96,6 @@ export namespace sampler {
k_dpmpp_2s_a: 'DPM++ 2S a',
k_dpmpp_sde: 'DPM++ SDE',
DDIM: 'DDIM',
k_lms_ka: 'LMS Karras',
k_heun_ka: 'Heun Karras',
k_euler_ka: 'Euler Karras',
k_euler_a_ka: 'Euler a Karras',
k_dpm_2_ka: 'DPM2 Karras',
k_dpm_2_a_ka: 'DPM2 a Karras',
k_dpm_fast_ka: 'DPM fast Karras',
k_dpm_adaptive_ka: 'DPM adaptive Karras',
k_dpmpp_2m_ka: 'DPM++ 2M Karras',
k_dpmpp_2s_a_ka: 'DPM++ 2S a Karras',
k_dpmpp_sde_ka: 'DPM++ SDE Karras',
DDIM_ka: 'DDIM Karras',
}

export function createSchema(map: Dict<string>) {
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function apply(ctx: Context, config: Config) {
.option('smea', '-S', { hidden: () => config.model !== 'nai-v3' })
.option('smeaDyn', '-d', { hidden: () => config.model !== 'nai-v3' })
.option('scheduler', '-C <scheduler> ', { hidden: () => config.model !== 'nai-v3', type: scheduler })
.option('karras', '-K', { hidden: useBackend('stable-horde') })
.option('decrisper', '-D', { hidden: thirdParty })
.option('undesired', '-u <undesired>')
.option('noTranslator', '-T', { hidden: () => !ctx.translator || !config.translator })
Expand Down Expand Up @@ -359,14 +360,14 @@ export function apply(ctx: Context, config: Config) {
return {
prompt: parameters.prompt,
params: {
sampler_name: options.sampler.replace('_ka', ''),
sampler_name: options.sampler,
cfg_scale: parameters.scale,
denoising_strength: parameters.strength,
seed: parameters.seed.toString(),
height: parameters.height,
width: parameters.width,
post_processing: [],
karras: options.sampler.includes('_ka'),
karras: options.karras,
hires_fix: options.hiresFix ?? config.hiresFix ?? false,
steps: parameters.steps,
n: parameters.n_samples,
Expand Down

0 comments on commit 061a87b

Please sign in to comment.