Spaces:
briaai
/
Running on Zero

Eyalgut commited on
Commit
2a47c9d
1 Parent(s): c13a51c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -19
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
- # print("Optimizing BRIA-2.2 - this could take a while")
29
- # t=time.time()
30
- # pipe.unet = torch.compile(
31
- # pipe.unet, mode="reduce-overhead", fullgraph=True # 600 secs compilation
32
- # )
33
- # with torch.no_grad():
34
- # outputs = pipe(
35
- # prompt="an apple",
36
- # num_inference_steps=30,
37
- # )
38
 
39
- # # This will avoid future compilations on different shapes
40
- # unet_compiled = torch._dynamo.run(pipe.unet)
41
- # unet_compiled.config=pipe.unet.config
42
- # unet_compiled.add_embedding = Dummy()
43
- # unet_compiled.add_embedding.linear_1 = Dummy()
44
- # unet_compiled.add_embedding.linear_1.in_features = pipe.unet.add_embedding.linear_1.in_features
45
- # pipe.unet = unet_compiled
46
 
47
- # print(f"Optimizing finished successfully after {time.time()-t} secs")
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):