Spaces:
Sleeping
Sleeping
rezaarmand
commited on
Commit
•
7da3063
1
Parent(s):
afd9e6c
change the cpu
Browse files
app.py
CHANGED
@@ -89,12 +89,11 @@ def predict(prompt, weights, seed, scale=7.5, steps=50):
|
|
89 |
try:
|
90 |
with torch.no_grad():
|
91 |
has_cuda = torch.cuda.is_available()
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
image_perpneg = pipe(prompt, guidance_scale=float(scale), generator=generator,
|
98 |
num_inference_steps=steps, weights=weights)["images"][0]
|
99 |
return image_perpneg
|
100 |
except Exception as e:
|
|
|
89 |
try:
|
90 |
with torch.no_grad():
|
91 |
has_cuda = torch.cuda.is_available()
|
92 |
+
if has_cuda:
|
93 |
+
generator = torch.Generator('cuda').manual_seed(int(seed))
|
94 |
+
else:
|
95 |
+
generator = torch.Generator().manual_seed(int(seed))
|
96 |
+
image_perpneg = pipe(prompt, guidance_scale=float(scale), generator=generator,
|
|
|
97 |
num_inference_steps=steps, weights=weights)["images"][0]
|
98 |
return image_perpneg
|
99 |
except Exception as e:
|