Spaces:
Running
on
Zero
Running
on
Zero
AlekseyCalvin
commited on
Commit
•
0e739bf
1
Parent(s):
2c82f8a
Update app.py
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ def generate_image(prompt, negative_prompt, width, height, steps, seed, lora_sca
|
|
119 |
with calculateDuration("Generating image"):
|
120 |
# Generate image
|
121 |
image = pipe(
|
122 |
-
prompt=f"{prompt}
|
123 |
negative_prompt=negative_prompt,
|
124 |
num_inference_steps=steps,
|
125 |
guidance_scale=cfg_scale,
|
@@ -138,17 +138,6 @@ def run_lora(prompt, negative_prompt, lora_scale, cfg_scale, steps, selected_ind
|
|
138 |
|
139 |
selected_lora = loras[selected_index]
|
140 |
lora_path = selected_lora["repo"]
|
141 |
-
trigger_word = selected_lora["trigger_word"]
|
142 |
-
if(trigger_word):
|
143 |
-
if "trigger_position" in selected_lora:
|
144 |
-
if selected_lora["trigger_position"] == "prepend":
|
145 |
-
prompt_mash = f"{trigger_word} {prompt}"
|
146 |
-
else:
|
147 |
-
prompt_mash = f"{prompt} {trigger_word}"
|
148 |
-
else:
|
149 |
-
prompt_mash = f"{trigger_word} {prompt}"
|
150 |
-
else:
|
151 |
-
prompt_mash = prompt
|
152 |
|
153 |
# Load LoRA weights
|
154 |
with calculateDuration(f"Loading LoRA weights for {selected_lora['title']}"):
|
@@ -167,7 +156,7 @@ def run_lora(prompt, negative_prompt, lora_scale, cfg_scale, steps, selected_ind
|
|
167 |
# pipe.load_lora_weights(lora_path, adapter_name=selected_lora["repo"], lora_scale=[1.0])
|
168 |
# pipe.set_adapters(["fast", selected_lora["repo"]], adapter_weights=[1.0, 1.0])
|
169 |
|
170 |
-
image = generate_image(prompt,
|
171 |
pipe.to("cpu")
|
172 |
pipe.unload_lora_weights()
|
173 |
return image, seed
|
@@ -246,7 +235,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
|
246 |
gr.on(
|
247 |
triggers=[generate_button.click, prompt.submit],
|
248 |
fn=run_lora,
|
249 |
-
inputs=[prompt,
|
250 |
outputs=[result, seed]
|
251 |
)
|
252 |
|
|
|
119 |
with calculateDuration("Generating image"):
|
120 |
# Generate image
|
121 |
image = pipe(
|
122 |
+
prompt=f"{prompt}",
|
123 |
negative_prompt=negative_prompt,
|
124 |
num_inference_steps=steps,
|
125 |
guidance_scale=cfg_scale,
|
|
|
138 |
|
139 |
selected_lora = loras[selected_index]
|
140 |
lora_path = selected_lora["repo"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
# Load LoRA weights
|
143 |
with calculateDuration(f"Loading LoRA weights for {selected_lora['title']}"):
|
|
|
156 |
# pipe.load_lora_weights(lora_path, adapter_name=selected_lora["repo"], lora_scale=[1.0])
|
157 |
# pipe.set_adapters(["fast", selected_lora["repo"]], adapter_weights=[1.0, 1.0])
|
158 |
|
159 |
+
image = generate_image(prompt, width, height, steps, negative_prompt, seed, lora_scale, cfg_scale)
|
160 |
pipe.to("cpu")
|
161 |
pipe.unload_lora_weights()
|
162 |
return image, seed
|
|
|
235 |
gr.on(
|
236 |
triggers=[generate_button.click, prompt.submit],
|
237 |
fn=run_lora,
|
238 |
+
inputs=[prompt, seed, width, height, steps, negative_prompt, lora_scale, cfg_scale, selected_index],
|
239 |
outputs=[result, seed]
|
240 |
)
|
241 |
|