Abdullah-Habib commited on
Commit
117fdd4
·
1 Parent(s): 4260ecb

testing with 2 loras

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -28,14 +28,14 @@ pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
28
  pipe.to("cuda")
29
 
30
  def update_selection(evt: gr.SelectData):
31
- selected_lora = loras[evt.index]
32
- new_placeholder = f"Type a prompt for {selected_lora['title']}"
33
- lora_repo = selected_lora["repo"]
34
- updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
35
  return (
36
  gr.update(placeholder=new_placeholder),
37
  updated_text,
38
- evt.index
39
  )
40
 
41
  @spaces.GPU
@@ -43,12 +43,13 @@ def run_lora(prompt, negative_prompt, cfg_scale, steps, selected_index, schedule
43
  if selected_index is None:
44
  raise gr.Error("You must select a LoRA before proceeding.")
45
 
46
- selected_lora = loras[selected_index]
47
- lora_path = selected_lora["repo"]
48
- trigger_word = selected_lora["trigger_word"]
49
 
50
  # Load LoRA weights
51
- pipe.load_lora_weights(lora_path)
 
52
 
53
  # Set scheduler
54
  scheduler_config = pipe.scheduler.config
@@ -92,7 +93,7 @@ def run_lora(prompt, negative_prompt, cfg_scale, steps, selected_index, schedule
92
 
93
  # Generate image
94
  image = pipe(
95
- prompt=f"{prompt} {trigger_word}",
96
  negative_prompt=negative_prompt,
97
  num_inference_steps=steps,
98
  guidance_scale=cfg_scale,
@@ -154,7 +155,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
154
  value="DPM++ 2M SDE Karras"
155
  )
156
 
157
- gallery.select(update_selection, outputs=[prompt, selected_info, selected_index])
158
 
159
  generate_button.click(
160
  fn=run_lora,
 
28
  pipe.to("cuda")
29
 
30
  def update_selection(evt: gr.SelectData):
31
+ # selected_lora = loras[evt.index]
32
+ new_placeholder = f"Type a prompt"
33
+ # lora_repo = selected_lora["repo"]
34
+ # updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
35
  return (
36
  gr.update(placeholder=new_placeholder),
37
  updated_text,
38
+ # evt.index
39
  )
40
 
41
  @spaces.GPU
 
43
  if selected_index is None:
44
  raise gr.Error("You must select a LoRA before proceeding.")
45
 
46
+ # selected_lora = loras[selected_index]
47
+ # # lora_path = selected_lora["repo"]
48
+ # trigger_word = selected_lora["trigger_word"]
49
 
50
  # Load LoRA weights
51
+ pipe.load_lora_weights("Abdullah-Habib/logolora")
52
+ pipe.load_lora_weights("Abdullah-Habib/icon-lora")
53
 
54
  # Set scheduler
55
  scheduler_config = pipe.scheduler.config
 
93
 
94
  # Generate image
95
  image = pipe(
96
+ prompt=f"{prompt} logo, logoredmaf, icons",
97
  negative_prompt=negative_prompt,
98
  num_inference_steps=steps,
99
  guidance_scale=cfg_scale,
 
155
  value="DPM++ 2M SDE Karras"
156
  )
157
 
158
+ gallery.select(update_selection, outputs=[prompt, selected_info])
159
 
160
  generate_button.click(
161
  fn=run_lora,