animrods commited on
Commit
7593258
·
verified ·
1 Parent(s): f66a588

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -22,7 +22,7 @@ MAX_SEED = np.iinfo(np.int32).max
22
 
23
  @spaces.GPU(enable_queue=True)
24
 
25
- def predict(prompt, upload_images, ip_adapter_scale=0.5, negative_prompt="", seed=100, randomize_seed=False, center_crop=False, width=1024, height=1024, guidance_scale=5.0, num_inference_steps=50, style="Basic", progress=gr.Progress(track_tqdm=True)):
26
  if randomize_seed:
27
  seed = random.randint(0, MAX_SEED)
28
 
@@ -38,11 +38,11 @@ def predict(prompt, upload_images, ip_adapter_scale=0.5, negative_prompt="", see
38
 
39
  generator = torch.Generator(device="cuda").manual_seed(seed)
40
 
41
- if style == "Style1":
42
  adapter_scale = {"down": {"block_2": [ip_adapter_scale, 0.0]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}, "mid": ip_adapter_scale}
43
- elif style == "Style2":
44
  adapter_scale = {"down": {"block_2": [ip_adapter_scale, ip_adapter_scale]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}}
45
- elif style == "Style3":
46
  adapter_scale = {"down": {"block_2": [ip_adapter_scale, 0.0], "block_1": [0.0, ip_adapter_scale]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}}
47
  else:
48
  adapter_scale = ip_adapter_scale
@@ -212,7 +212,7 @@ with gr.Blocks(css=css) as demo:
212
  gr.on(
213
  triggers=[run_button.click, prompt.submit],
214
  fn=predict,
215
- inputs=[prompt, files, ip_adapter_scale, negative_prompt, seed, randomize_seed, center_crop, width, height, guidance_scale, num_inference_steps, style],
216
  outputs=[result, seed]
217
  )
218
 
 
22
 
23
  @spaces.GPU(enable_queue=True)
24
 
25
+ def predict(prompt, upload_images, ip_adapter_scale=0.5, negative_prompt="", seed=100, randomize_seed=False, center_crop=False, width=1024, height=1024, guidance_scale=5.0, num_inference_steps=50, mode="Basic", progress=gr.Progress(track_tqdm=True)):
26
  if randomize_seed:
27
  seed = random.randint(0, MAX_SEED)
28
 
 
38
 
39
  generator = torch.Generator(device="cuda").manual_seed(seed)
40
 
41
+ if mode == "Style-Only":
42
  adapter_scale = {"down": {"block_2": [ip_adapter_scale, 0.0]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}, "mid": ip_adapter_scale}
43
+ elif mode == "Style2":
44
  adapter_scale = {"down": {"block_2": [ip_adapter_scale, ip_adapter_scale]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}}
45
+ elif mode == "Style3":
46
  adapter_scale = {"down": {"block_2": [ip_adapter_scale, 0.0], "block_1": [0.0, ip_adapter_scale]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}}
47
  else:
48
  adapter_scale = ip_adapter_scale
 
212
  gr.on(
213
  triggers=[run_button.click, prompt.submit],
214
  fn=predict,
215
+ inputs=[prompt, files, ip_adapter_scale, negative_prompt, seed, randomize_seed, center_crop, width, height, guidance_scale, num_inference_steps, mode],
216
  outputs=[result, seed]
217
  )
218