Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
28a1edd
1
Parent(s):
e725300
Update app.py
Browse files
app.py
CHANGED
@@ -6,25 +6,6 @@ from PIL import Image
|
|
6 |
import random
|
7 |
import os
|
8 |
|
9 |
-
model_id = 'aipicasso/picasso-diffusion-1-0'
|
10 |
-
token=os.environ.get("ACCESS_TOKEN")
|
11 |
-
|
12 |
-
scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler", use_auth_token=token)
|
13 |
-
feature_extractor = CLIPFeatureExtractor.from_pretrained(model_id, use_auth_token=token)
|
14 |
-
|
15 |
-
pipe_org = StableDiffusionPipeline.from_pretrained(
|
16 |
-
model_id,
|
17 |
-
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
18 |
-
scheduler=scheduler, use_auth_token=token)
|
19 |
-
|
20 |
-
pipe_i2i_org = StableDiffusionImg2ImgPipeline.from_pretrained(
|
21 |
-
model_id,
|
22 |
-
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
23 |
-
scheduler=scheduler,
|
24 |
-
requires_safety_checker=False,
|
25 |
-
safety_checker=None,
|
26 |
-
feature_extractor=feature_extractor, use_auth_token=token
|
27 |
-
)
|
28 |
|
29 |
model_id = 'aipicasso/picasso-diffusion-1-0-demo'
|
30 |
token=os.environ.get("ACCESS_TOKEN")
|
@@ -48,6 +29,8 @@ pipe_i2i_merged = StableDiffusionImg2ImgPipeline.from_pretrained(
|
|
48 |
|
49 |
pipe=pipe_merged.to("cuda")
|
50 |
pipe_i2i=pipe_i2i_merged.to("cuda")
|
|
|
|
|
51 |
|
52 |
def error_str(error, title="Error"):
|
53 |
return f"""#### {title}
|
@@ -55,18 +38,6 @@ def error_str(error, title="Error"):
|
|
55 |
|
56 |
def inference(prompt, guidance, steps, image_size="Square", seed=0, img=None, strength=0.5, neg_prompt="", disable_auto_prompt_correction=False, original_model=False):
|
57 |
global pipe,pipe_i2i
|
58 |
-
|
59 |
-
if torch.cuda.is_available():
|
60 |
-
pipe=pipe.to("cpu")
|
61 |
-
pipe_i2i=pipe_i2i.to("cpu")
|
62 |
-
if original_model:
|
63 |
-
pipe = pipe_org.to("cuda")
|
64 |
-
pipe_i2i = pipe_i2i_org.to("cuda")
|
65 |
-
else:
|
66 |
-
pipe = pipe_merged.to("cuda")
|
67 |
-
pipe_i2i = pipe_merged.to("cuda")
|
68 |
-
pipe.enable_xformers_memory_efficient_attention()
|
69 |
-
pipe_i2i.enable_xformers_memory_efficient_attention()
|
70 |
|
71 |
generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
|
72 |
|
|
|
6 |
import random
|
7 |
import os
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
model_id = 'aipicasso/picasso-diffusion-1-0-demo'
|
11 |
token=os.environ.get("ACCESS_TOKEN")
|
|
|
29 |
|
30 |
pipe=pipe_merged.to("cuda")
|
31 |
pipe_i2i=pipe_i2i_merged.to("cuda")
|
32 |
+
pipe.enable_xformers_memory_efficient_attention()
|
33 |
+
pipe_i2i.enable_xformers_memory_efficient_attention()
|
34 |
|
35 |
def error_str(error, title="Error"):
|
36 |
return f"""#### {title}
|
|
|
38 |
|
39 |
def inference(prompt, guidance, steps, image_size="Square", seed=0, img=None, strength=0.5, neg_prompt="", disable_auto_prompt_correction=False, original_model=False):
|
40 |
global pipe,pipe_i2i
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
|
43 |
|