cocktailpeanut commited on
Commit
e155299
1 Parent(s): e398fab

allow custom size

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -238,7 +238,7 @@ def merge_incompatible_lora(full_path_lora, lora_scale):
238
  del weights_sd
239
  del lora_model
240
  #@spaces.GPU
241
- def generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, repo_name, loaded_state_dict, lora_scale, sdxl_loras, selected_state_index, st):
242
  print(loaded_state_dict)
243
  et = time.time()
244
  elapsed_time = et - st
@@ -303,8 +303,8 @@ def generate_image(prompt, negative, face_emb, face_image, face_kps, image_stren
303
  pooled_prompt_embeds=pooled,
304
  negative_prompt_embeds=negative_conditioning,
305
  negative_pooled_prompt_embeds=negative_pooled,
306
- width=1024,
307
- height=1024,
308
  image_embeds=face_emb,
309
  image=face_image,
310
  strength=1-image_strength,
@@ -319,7 +319,7 @@ def generate_image(prompt, negative, face_emb, face_image, face_kps, image_stren
319
  last_lora = repo_name
320
  return image
321
 
322
- def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, sdxl_loras, custom_lora, progress=gr.Progress(track_tqdm=True)):
323
  print("Custom LoRA: ", custom_lora)
324
  custom_lora_path = custom_lora[0] if custom_lora else None
325
  selected_state_index = selected_state.index if selected_state else -1
@@ -373,7 +373,7 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
373
  print('Small content processing took: ', elapsed_time, 'seconds')
374
 
375
  st = time.time()
376
- image = generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, repo_name, full_path_lora, lora_scale, sdxl_loras, selected_state_index, st)
377
  return image, gr.update(visible=True)
378
 
379
  def shuffle_gallery(sdxl_loras):
@@ -539,6 +539,7 @@ with gr.Blocks(css="custom.css") as demo:
539
  with gr.Row():
540
  prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, info="Describe your subject (optional)", value="a person", elem_id="prompt")
541
  button = gr.Button("Run", elem_id="run_button")
 
542
  result = gr.Image(
543
  interactive=False, label="Generated Image", elem_id="result-image"
544
  )
@@ -595,7 +596,7 @@ with gr.Blocks(css="custom.css") as demo:
595
  show_progress=False
596
  ).success(
597
  fn=run_lora,
598
- inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, custom_loaded_lora],
599
  outputs=[result, share_group],
600
  )
601
  button.click(
@@ -605,7 +606,7 @@ with gr.Blocks(css="custom.css") as demo:
605
  show_progress=False
606
  ).success(
607
  fn=run_lora,
608
- inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, custom_loaded_lora],
609
  outputs=[result, share_group],
610
  )
611
  share_button.click(None, [], [], js=share_js)
 
238
  del weights_sd
239
  del lora_model
240
  #@spaces.GPU
241
+ def generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, repo_name, loaded_state_dict, lora_scale, sdxl_loras, selected_state_index, size, st):
242
  print(loaded_state_dict)
243
  et = time.time()
244
  elapsed_time = et - st
 
303
  pooled_prompt_embeds=pooled,
304
  negative_prompt_embeds=negative_conditioning,
305
  negative_pooled_prompt_embeds=negative_pooled,
306
+ width=int(size),
307
+ height=int(size),
308
  image_embeds=face_emb,
309
  image=face_image,
310
  strength=1-image_strength,
 
319
  last_lora = repo_name
320
  return image
321
 
322
+ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, sdxl_loras, custom_lora, size, progress=gr.Progress(track_tqdm=True)):
323
  print("Custom LoRA: ", custom_lora)
324
  custom_lora_path = custom_lora[0] if custom_lora else None
325
  selected_state_index = selected_state.index if selected_state else -1
 
373
  print('Small content processing took: ', elapsed_time, 'seconds')
374
 
375
  st = time.time()
376
+ image = generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, repo_name, full_path_lora, lora_scale, sdxl_loras, selected_state_index, size, st)
377
  return image, gr.update(visible=True)
378
 
379
  def shuffle_gallery(sdxl_loras):
 
539
  with gr.Row():
540
  prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, info="Describe your subject (optional)", value="a person", elem_id="prompt")
541
  button = gr.Button("Run", elem_id="run_button")
542
+ size = gr.Slider(minimum=512, maximum=1024, step=128, value=1024, interactive=True)
543
  result = gr.Image(
544
  interactive=False, label="Generated Image", elem_id="result-image"
545
  )
 
596
  show_progress=False
597
  ).success(
598
  fn=run_lora,
599
+ inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, custom_loaded_lora, size],
600
  outputs=[result, share_group],
601
  )
602
  button.click(
 
606
  show_progress=False
607
  ).success(
608
  fn=run_lora,
609
+ inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, custom_loaded_lora, size],
610
  outputs=[result, share_group],
611
  )
612
  share_button.click(None, [], [], js=share_js)