aboutsummaryrefslogtreecommitdiffstats
path: root/extensions-builtin/LDSR
diff options
context:
space:
mode:
authorwywywywy <wywywywy@gmail.com>2022-12-10 14:07:27 +0000
committerwywywywy <wywywywy@gmail.com>2022-12-10 14:07:27 +0000
commit1581d5a1674fbbeaf047b79f3a138781d6322e6e (patch)
tree1380c22301c8c0d993c793db1ad9d1cd610d5eb7 /extensions-builtin/LDSR
parent6df316c881b533731faa77494ea01533e35f8dc7 (diff)
downloadstable-diffusion-webui-gfx803-1581d5a1674fbbeaf047b79f3a138781d6322e6e.tar.gz
stable-diffusion-webui-gfx803-1581d5a1674fbbeaf047b79f3a138781d6322e6e.tar.bz2
stable-diffusion-webui-gfx803-1581d5a1674fbbeaf047b79f3a138781d6322e6e.zip
Made device agnostic
Diffstat (limited to 'extensions-builtin/LDSR')
-rw-r--r--extensions-builtin/LDSR/ldsr_model_arch.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/extensions-builtin/LDSR/ldsr_model_arch.py b/extensions-builtin/LDSR/ldsr_model_arch.py
index 9ec4e67e..8b048ae0 100644
--- a/extensions-builtin/LDSR/ldsr_model_arch.py
+++ b/extensions-builtin/LDSR/ldsr_model_arch.py
@@ -110,7 +110,8 @@ class LDSR:
down_sample_method = 'Lanczos'
gc.collect()
- torch.cuda.empty_cache()
+ if torch.cuda.is_available:
+ torch.cuda.empty_cache()
im_og = image
width_og, height_og = im_og.size
@@ -147,7 +148,9 @@ class LDSR:
del model
gc.collect()
- torch.cuda.empty_cache()
+ if torch.cuda.is_available:
+ torch.cuda.empty_cache()
+
return a
@@ -162,7 +165,7 @@ def get_cond(selected_path):
c = rearrange(c, '1 c h w -> 1 h w c')
c = 2. * c - 1.
- c = c.to(torch.device("cuda"))
+ c = c.to(shared.device)
example["LR_image"] = c
example["image"] = c_up