Skip to content

Commit

Permalink
add k_dpmpp_2_a and k_dpmpp_2 solvers options (#1389)
Browse files Browse the repository at this point in the history
* add k_dpmpp_2_a and k_dpmpp_2 solvers options

* update frontend

Co-authored-by: Victor <[email protected]>
Co-authored-by: Lincoln Stein <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2022
1 parent a9aa4e4 commit 2443e5d
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 1,127 deletions.
2 changes: 2 additions & 0 deletions backend/modules/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"ddim",
"k_dpm_2_a",
"k_dpm_2",
"k_dpmpp_2_a",
"k_dpmpp_2",
"k_euler_a",
"k_euler",
"k_heun",
Expand Down
623 changes: 0 additions & 623 deletions frontend/dist/assets/index.2b7cd976.js

This file was deleted.

501 changes: 0 additions & 501 deletions frontend/dist/assets/index.678a45f6.js

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>InvokeAI - A Stable Diffusion Toolkit</title>
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
<script type="module" crossorigin src="./assets/index.2b7cd976.js"></script>
<script type="module" crossorigin src="./assets/index.f1b8da92.js"></script>
<link rel="stylesheet" href="./assets/index.f999e69e.css">
</head>

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const SAMPLERS: Array<string> = [
'k_lms',
'k_dpm_2',
'k_dpm_2_a',
'k_dpmpp_2',
'k_dpmpp_2_a',
'k_euler',
'k_euler_a',
'k_heun',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/invokeai.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export declare type CommonGeneratedImageMetadata = {
| 'ddim'
| 'k_dpm_2_a'
| 'k_dpm_2'
| 'k_dpmpp_2_a'
| 'k_dpmpp_2'
| 'k_euler_a'
| 'k_euler'
| 'k_heun'
Expand Down
6 changes: 5 additions & 1 deletion ldm/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def new_func(*args, **kw):
safety_checker:bool = activate safety checker [False]
# this value is sticky and maintained between generation calls
sampler_name:str = ['ddim', 'k_dpm_2_a', 'k_dpm_2', 'k_euler_a', 'k_euler', 'k_heun', 'k_lms', 'plms'] // k_lms
sampler_name:str = ['ddim', 'k_dpm_2_a', 'k_dpm_2', 'k_dpmpp_2', 'k_dpmpp_2_a', 'k_euler_a', 'k_euler', 'k_heun', 'k_lms', 'plms'] // k_lms
# these are deprecated - use conf and model instead
weights = path to model weights ('models/ldm/stable-diffusion-v1/model.ckpt')
Expand Down Expand Up @@ -974,6 +974,10 @@ def _set_sampler(self):
self.sampler = KSampler(self.model, 'dpm_2_ancestral', device=self.device)
elif self.sampler_name == 'k_dpm_2':
self.sampler = KSampler(self.model, 'dpm_2', device=self.device)
elif self.sampler_name == 'k_dpmpp_2_a':
self.sampler = KSampler(self.model, 'dpmpp_2s_ancestral', device=self.device)
elif self.sampler_name == 'k_dpmpp_2':
self.sampler = KSampler(self.model, 'dpmpp_2m', device=self.device)
elif self.sampler_name == 'k_euler_a':
self.sampler = KSampler(self.model, 'euler_ancestral', device=self.device)
elif self.sampler_name == 'k_euler':
Expand Down
2 changes: 2 additions & 0 deletions ldm/invoke/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
'ddim',
'k_dpm_2_a',
'k_dpm_2',
'k_dpmpp_2_a',
'k_dpmpp_2',
'k_euler_a',
'k_euler',
'k_heun',
Expand Down
2 changes: 1 addition & 1 deletion ldm/models/diffusion/ddpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ def p_losses(self, x_start, cond, t, noise=None):
)
loss_dict.update({f'{prefix}/loss_simple': loss_simple.mean()})

logvar_t = self.logvar[t].to(self.device)
logvar_t = self.logvar[t.item()].to(self.device)
loss = loss_simple / torch.exp(logvar_t) + logvar_t
# loss = loss_simple / torch.exp(self.logvar) + self.logvar
if self.learn_logvar:
Expand Down
2 changes: 2 additions & 0 deletions scripts/legacy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ def write_log_message(results, log_path):
'ddim',
'k_dpm_2_a',
'k_dpm_2',
'k_dpmpp_2_a',
'k_dpmpp_2',
'k_euler_a',
'k_euler',
'k_heun',
Expand Down
2 changes: 2 additions & 0 deletions static/dream_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ <h1>Stable Diffusion Dream Server</h1>
<option value="k_lms" selected>KLMS</option>
<option value="k_dpm_2">KDPM_2</option>
<option value="k_dpm_2_a">KDPM_2A</option>
<option value="k_dpmpp_2">KDPMPP_2</option>
<option value="k_dpmpp_2_a">KDPMPP_2A</option>
<option value="k_euler">KEULER</option>
<option value="k_euler_a">KEULER_A</option>
<option value="k_heun">KHEUN</option>
Expand Down
2 changes: 2 additions & 0 deletions static/legacy_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ <h1>Stable Diffusion Dream Server</h1>
<option value="k_lms" selected>KLMS</option>
<option value="k_dpm_2">KDPM_2</option>
<option value="k_dpm_2_a">KDPM_2A</option>
<option value="k_dpmpp_2">KDPMPP_2</option>
<option value="k_dpmpp_2_a">KDPMPP_2A</option>
<option value="k_euler">KEULER</option>
<option value="k_euler_a">KEULER_A</option>
<option value="k_heun">KHEUN</option>
Expand Down

0 comments on commit 2443e5d

Please sign in to comment.