Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dream.py. k_euler_a and k_dpm_2_a M1 fix #579

Merged
merged 6 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ldm/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@
from ldm.dream.devices import choose_torch_device
from ldm.dream.conditioning import get_uc_and_c

def fix_func(orig):
if hasattr(torch.backends, 'mps') and torch.backends.mps.is_available():
def new_func(*args, **kw):
device = kw.get("device", "mps")
kw["device"]="cpu"
return orig(*args, **kw).to(device)
return new_func
return orig

torch.rand = fix_func(torch.rand)
torch.rand_like = fix_func(torch.rand_like)
torch.randn = fix_func(torch.randn)
torch.randn_like = fix_func(torch.randn_like)
torch.randint = fix_func(torch.randint)
torch.randint_like = fix_func(torch.randint_like)
torch.bernoulli = fix_func(torch.bernoulli)
torch.multinomial = fix_func(torch.multinomial)

"""Simplified text to image API for stable diffusion/latent diffusion

Example Usage:
Expand Down
1 change: 0 additions & 1 deletion scripts/dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Just want to get the formatting look right for now.
output_cntr = 0


def main():
"""Initialize command-line parsers and the diffusion model"""
arg_parser = create_argv_parser()
Expand Down