Spaces:
Running
on
Zero
Running
on
Zero
AlekseyCalvin
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,7 @@ def update_selection(evt: gr.SelectData, width, height):
|
|
104 |
)
|
105 |
|
106 |
@spaces.GPU(duration=70)
|
107 |
-
def generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, negative_prompt,
|
108 |
pipe.to("cuda")
|
109 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
110 |
|
@@ -118,12 +118,12 @@ def generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height,
|
|
118 |
height=height,
|
119 |
generator=generator,
|
120 |
negative_prompt=negative_prompt,
|
121 |
-
no_cfg_until_timestep=2,
|
122 |
joint_attention_kwargs={"scale": lora_scale},
|
|
|
123 |
).images[0]
|
124 |
return image
|
125 |
|
126 |
-
def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, width, height, negative_prompt, no_cfg_until_timestep=2,
|
127 |
if selected_index is None:
|
128 |
raise gr.Error("You must select a LoRA before proceeding.")
|
129 |
|
@@ -153,7 +153,7 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, wid
|
|
153 |
if randomize_seed:
|
154 |
seed = random.randint(0, MAX_SEED)
|
155 |
|
156 |
-
image = generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, negative_prompt,
|
157 |
pipe.to("cpu")
|
158 |
pipe.unload_lora_weights()
|
159 |
return image, seed
|
|
|
104 |
)
|
105 |
|
106 |
@spaces.GPU(duration=70)
|
107 |
+
def generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, negative_prompt, lora_scale, progress, no_cfg_until_timestep):
|
108 |
pipe.to("cuda")
|
109 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
110 |
|
|
|
118 |
height=height,
|
119 |
generator=generator,
|
120 |
negative_prompt=negative_prompt,
|
|
|
121 |
joint_attention_kwargs={"scale": lora_scale},
|
122 |
+
no_cfg_until_timestep=2,
|
123 |
).images[0]
|
124 |
return image
|
125 |
|
126 |
+
def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, width, height, negative_prompt, lora_scale, no_cfg_until_timestep=2, progress=gr.Progress(track_tqdm=True)):
|
127 |
if selected_index is None:
|
128 |
raise gr.Error("You must select a LoRA before proceeding.")
|
129 |
|
|
|
153 |
if randomize_seed:
|
154 |
seed = random.randint(0, MAX_SEED)
|
155 |
|
156 |
+
image = generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, negative_prompt, lora_scale, progress, no_cfg_until_timestep)
|
157 |
pipe.to("cpu")
|
158 |
pipe.unload_lora_weights()
|
159 |
return image, seed
|