Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
1f6a467e
Commit
1f6a467e
authored
Feb 09, 2023
by
comfyanonymous
Browse files
Update ldm dir with latest upstream stable diffusion changes.
parent
642516a3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
10 deletions
+21
-10
comfy/ldm/models/diffusion/ddim.py
comfy/ldm/models/diffusion/ddim.py
+4
-3
comfy/ldm/models/diffusion/ddpm.py
comfy/ldm/models/diffusion/ddpm.py
+7
-1
comfy/ldm/models/diffusion/dpm_solver/sampler.py
comfy/ldm/models/diffusion/dpm_solver/sampler.py
+4
-3
comfy/ldm/models/diffusion/plms.py
comfy/ldm/models/diffusion/plms.py
+4
-3
comfy/ldm/modules/diffusionmodules/openaimodel.py
comfy/ldm/modules/diffusionmodules/openaimodel.py
+2
-0
No files found.
comfy/ldm/models/diffusion/ddim.py
View file @
1f6a467e
...
...
@@ -8,16 +8,17 @@ from ldm.modules.diffusionmodules.util import make_ddim_sampling_parameters, mak
class
DDIMSampler
(
object
):
def
__init__
(
self
,
model
,
schedule
=
"linear"
,
**
kwargs
):
def
__init__
(
self
,
model
,
schedule
=
"linear"
,
device
=
torch
.
device
(
"cuda"
),
**
kwargs
):
super
().
__init__
()
self
.
model
=
model
self
.
ddpm_num_timesteps
=
model
.
num_timesteps
self
.
schedule
=
schedule
self
.
device
=
device
def
register_buffer
(
self
,
name
,
attr
):
if
type
(
attr
)
==
torch
.
Tensor
:
if
attr
.
device
!=
torch
.
device
(
"cuda"
)
:
attr
=
attr
.
to
(
torch
.
device
(
"cuda"
)
)
if
attr
.
device
!=
self
.
device
:
attr
=
attr
.
to
(
self
.
device
)
setattr
(
self
,
name
,
attr
)
def
make_schedule
(
self
,
ddim_num_steps
,
ddim_discretize
=
"uniform"
,
ddim_eta
=
0.
,
verbose
=
True
):
...
...
comfy/ldm/models/diffusion/ddpm.py
View file @
1f6a467e
...
...
@@ -1331,6 +1331,12 @@ class DiffusionWrapper(torch.nn.Module):
cc
=
torch
.
cat
(
c_crossattn
,
1
)
else
:
cc
=
c_crossattn
if
hasattr
(
self
,
"scripted_diffusion_model"
):
# TorchScript changes names of the arguments
# with argument cc defined as context=cc scripted model will produce
# an error: RuntimeError: forward() is missing value for argument 'argument_3'.
out
=
self
.
scripted_diffusion_model
(
x
,
t
,
cc
)
else
:
out
=
self
.
diffusion_model
(
x
,
t
,
context
=
cc
)
elif
self
.
conditioning_key
==
'hybrid'
:
xc
=
torch
.
cat
([
x
]
+
c_concat
,
dim
=
1
)
...
...
comfy/ldm/models/diffusion/dpm_solver/sampler.py
View file @
1f6a467e
...
...
@@ -11,16 +11,17 @@ MODEL_TYPES = {
class
DPMSolverSampler
(
object
):
def
__init__
(
self
,
model
,
**
kwargs
):
def
__init__
(
self
,
model
,
device
=
torch
.
device
(
"cuda"
),
**
kwargs
):
super
().
__init__
()
self
.
model
=
model
self
.
device
=
device
to_torch
=
lambda
x
:
x
.
clone
().
detach
().
to
(
torch
.
float32
).
to
(
model
.
device
)
self
.
register_buffer
(
'alphas_cumprod'
,
to_torch
(
model
.
alphas_cumprod
))
def
register_buffer
(
self
,
name
,
attr
):
if
type
(
attr
)
==
torch
.
Tensor
:
if
attr
.
device
!=
torch
.
device
(
"cuda"
)
:
attr
=
attr
.
to
(
torch
.
device
(
"cuda"
)
)
if
attr
.
device
!=
self
.
device
:
attr
=
attr
.
to
(
self
.
device
)
setattr
(
self
,
name
,
attr
)
@
torch
.
no_grad
()
...
...
comfy/ldm/models/diffusion/plms.py
View file @
1f6a467e
...
...
@@ -10,16 +10,17 @@ from ldm.models.diffusion.sampling_util import norm_thresholding
class
PLMSSampler
(
object
):
def
__init__
(
self
,
model
,
schedule
=
"linear"
,
**
kwargs
):
def
__init__
(
self
,
model
,
schedule
=
"linear"
,
device
=
torch
.
device
(
"cuda"
),
**
kwargs
):
super
().
__init__
()
self
.
model
=
model
self
.
ddpm_num_timesteps
=
model
.
num_timesteps
self
.
schedule
=
schedule
self
.
device
=
device
def
register_buffer
(
self
,
name
,
attr
):
if
type
(
attr
)
==
torch
.
Tensor
:
if
attr
.
device
!=
torch
.
device
(
"cuda"
)
:
attr
=
attr
.
to
(
torch
.
device
(
"cuda"
)
)
if
attr
.
device
!=
self
.
device
:
attr
=
attr
.
to
(
self
.
device
)
setattr
(
self
,
name
,
attr
)
def
make_schedule
(
self
,
ddim_num_steps
,
ddim_discretize
=
"uniform"
,
ddim_eta
=
0.
,
verbose
=
True
):
...
...
comfy/ldm/modules/diffusionmodules/openaimodel.py
View file @
1f6a467e
...
...
@@ -454,6 +454,7 @@ class UNetModel(nn.Module):
num_classes
=
None
,
use_checkpoint
=
False
,
use_fp16
=
False
,
use_bf16
=
False
,
num_heads
=-
1
,
num_head_channels
=-
1
,
num_heads_upsample
=-
1
,
...
...
@@ -518,6 +519,7 @@ class UNetModel(nn.Module):
self
.
num_classes
=
num_classes
self
.
use_checkpoint
=
use_checkpoint
self
.
dtype
=
th
.
float16
if
use_fp16
else
th
.
float32
self
.
dtype
=
th
.
bfloat16
if
use_bf16
else
self
.
dtype
self
.
num_heads
=
num_heads
self
.
num_head_channels
=
num_head_channels
self
.
num_heads_upsample
=
num_heads_upsample
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment