jychen0828 commited on
Commit
9c46709
·
verified ·
1 Parent(s): f66e410

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
app.py CHANGED
@@ -45,6 +45,27 @@ h1 {
45
  }
46
  """
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  with gr.Blocks(css=css) as demo:
49
  gr.Markdown(
50
  """
@@ -125,26 +146,6 @@ with gr.Blocks(css=css) as demo:
125
  """
126
  )
127
 
128
- @spaces.GPU
129
- def process_image(prompt,acc,height, width, steps, scales, seed):
130
- global pipe
131
- global loaded_acc
132
- if loaded_acc != acc:
133
- #pipe.load_lora_weights(ACC_lora[acc], adapter_name=acc)
134
- pipe.set_adapters([acc], adapter_weights=[1.0])
135
- print(pipe.get_active_adapters())
136
- loaded_acc = acc
137
- with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16), timer("inference"):
138
- return pipe(
139
- prompt=[prompt],
140
- generator=torch.Generator().manual_seed(int(seed)),
141
- num_inference_steps=int(steps),
142
- guidance_scale=float(scales),
143
- height=int(height),
144
- width=int(width),
145
- max_sequence_length=256
146
- ).images[0]
147
-
148
  generate_btn.click(
149
  process_image,
150
  inputs=[prompt, acc,height, width, steps, scales, seed],
 
45
  }
46
  """
47
 
48
+ @spaces.GPU
49
+ def process_image(prompt,acc,height, width, steps, scales, seed):
50
+ global pipe
51
+ global loaded_acc
52
+ if loaded_acc != acc:
53
+ #pipe.load_lora_weights(ACC_lora[acc], adapter_name=acc)
54
+ pipe.set_adapters([acc], adapter_weights=[1.0])
55
+ print(pipe.get_active_adapters())
56
+ loaded_acc = acc
57
+ with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16), timer("inference"):
58
+ return pipe(
59
+ prompt=[prompt],
60
+ generator=torch.Generator().manual_seed(int(seed)),
61
+ num_inference_steps=int(steps),
62
+ guidance_scale=float(scales),
63
+ height=int(height),
64
+ width=int(width),
65
+ max_sequence_length=256
66
+ ).images[0]
67
+
68
+
69
  with gr.Blocks(css=css) as demo:
70
  gr.Markdown(
71
  """
 
146
  """
147
  )
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  generate_btn.click(
150
  process_image,
151
  inputs=[prompt, acc,height, width, steps, scales, seed],