Spaces:
Running
on
Zero
Running
on
Zero
AlekseyCalvin
commited on
Commit
•
041bd77
1
Parent(s):
b44f918
Update app.py
Browse files
app.py
CHANGED
@@ -127,7 +127,7 @@ def generate_image(prompt, negative_prompt, trigger_word, steps, seed, cfg_scale
|
|
127 |
).images[0]
|
128 |
return image
|
129 |
|
130 |
-
def run_lora(prompt, negative_prompt, cfg_scale, steps, selected_index,
|
131 |
if negative_prompt == "":
|
132 |
negative_prompt = None
|
133 |
if selected_index is None:
|
@@ -155,13 +155,8 @@ def run_lora(prompt, negative_prompt, cfg_scale, steps, selected_index, randomiz
|
|
155 |
else:
|
156 |
pipe.load_lora_weights("ostris/OpenFLUX.1", weight_name="openflux1-v0.1.0-fast-lora.safetensors", adapter_weights=[1.0])
|
157 |
pipe.load_lora_weights(lora_path, adapter_name=selected_lora["repo"], adapter_weights=lora_scale)
|
158 |
-
|
159 |
-
# Set random seed for reproducibility
|
160 |
-
with calculateDuration("Randomizing seed"):
|
161 |
-
if randomize_seed:
|
162 |
-
seed = random.randint(0, MAX_SEED)
|
163 |
|
164 |
-
image = generate_image(prompt, negative_prompt,
|
165 |
pipe.to("cpu")
|
166 |
pipe.unload_lora_weights()
|
167 |
return image, seed
|
@@ -228,7 +223,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
|
228 |
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=1024)
|
229 |
|
230 |
with gr.Row():
|
231 |
-
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
232 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
233 |
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=2.0, step=0.01, value=0.85)
|
234 |
|
@@ -241,7 +235,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
|
241 |
gr.on(
|
242 |
triggers=[generate_button.click, prompt.submit],
|
243 |
fn=run_lora,
|
244 |
-
inputs=[prompt, negative_prompt, cfg_scale, steps, selected_index,
|
245 |
outputs=[result, seed]
|
246 |
)
|
247 |
|
|
|
127 |
).images[0]
|
128 |
return image
|
129 |
|
130 |
+
def run_lora(prompt, negative_prompt, cfg_scale, steps, selected_index, seed, width, height, lora_scale, progress=gr.Progress(track_tqdm=True)):
|
131 |
if negative_prompt == "":
|
132 |
negative_prompt = None
|
133 |
if selected_index is None:
|
|
|
155 |
else:
|
156 |
pipe.load_lora_weights("ostris/OpenFLUX.1", weight_name="openflux1-v0.1.0-fast-lora.safetensors", adapter_weights=[1.0])
|
157 |
pipe.load_lora_weights(lora_path, adapter_name=selected_lora["repo"], adapter_weights=lora_scale)
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
+
image = generate_image(prompt, negative_prompt, steps, seed, cfg_scale, width, height, lora_scale, progress)
|
160 |
pipe.to("cpu")
|
161 |
pipe.unload_lora_weights()
|
162 |
return image, seed
|
|
|
223 |
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=1024)
|
224 |
|
225 |
with gr.Row():
|
|
|
226 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
227 |
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=2.0, step=0.01, value=0.85)
|
228 |
|
|
|
235 |
gr.on(
|
236 |
triggers=[generate_button.click, prompt.submit],
|
237 |
fn=run_lora,
|
238 |
+
inputs=[prompt, negative_prompt, cfg_scale, steps, selected_index, seed, width, height, lora_scale],
|
239 |
outputs=[result, seed]
|
240 |
)
|
241 |
|