Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import time
|
|
9 |
class Dummy():
|
10 |
pass
|
11 |
|
12 |
-
resolutions = ["1024 1024","1344 768","768 1344"]
|
13 |
|
14 |
# Ng
|
15 |
default_negative_prompt= "Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"
|
@@ -24,27 +24,28 @@ scheduler = EulerAncestralDiscreteScheduler(
|
|
24 |
steps_offset=1
|
25 |
)
|
26 |
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16,scheduler=scheduler).to("cuda")
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
|
49 |
@spaces.GPU(enable_queue=True)
|
50 |
def infer(prompt,negative_prompt,seed,resolution):
|
|
|
9 |
class Dummy():
|
10 |
pass
|
11 |
|
12 |
+
resolutions = ["1024 1024","1280 768","1344 768","768 1344","768 1280"]
|
13 |
|
14 |
# Ng
|
15 |
default_negative_prompt= "Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"
|
|
|
24 |
steps_offset=1
|
25 |
)
|
26 |
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16,scheduler=scheduler).to("cuda")
|
27 |
+
pipe.force_zeros_for_empty_prompt = False
|
28 |
|
29 |
+
print("Optimizing BRIA-2.2 - this could take a while")
|
30 |
+
t=time.time()
|
31 |
+
pipe.unet = torch.compile(
|
32 |
+
pipe.unet, mode="reduce-overhead", fullgraph=True # 600 secs compilation
|
33 |
+
)
|
34 |
+
with torch.no_grad():
|
35 |
+
outputs = pipe(
|
36 |
+
prompt="an apple",
|
37 |
+
num_inference_steps=30,
|
38 |
+
)
|
39 |
|
40 |
+
# This will avoid future compilations on different shapes
|
41 |
+
unet_compiled = torch._dynamo.run(pipe.unet)
|
42 |
+
unet_compiled.config=pipe.unet.config
|
43 |
+
unet_compiled.add_embedding = Dummy()
|
44 |
+
unet_compiled.add_embedding.linear_1 = Dummy()
|
45 |
+
unet_compiled.add_embedding.linear_1.in_features = pipe.unet.add_embedding.linear_1.in_features
|
46 |
+
pipe.unet = unet_compiled
|
47 |
|
48 |
+
print(f"Optimizing finished successfully after {time.time()-t} secs")
|
49 |
|
50 |
@spaces.GPU(enable_queue=True)
|
51 |
def infer(prompt,negative_prompt,seed,resolution):
|