Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -106,17 +106,9 @@ def load_b_loras(content_b_lora, style_b_lora):
|
|
106 |
style_model_instance_prompt = ''
|
107 |
|
108 |
prepared_prompt = f"{content_model_instance_prompt} {style_model_instance_prompt}"
|
109 |
-
|
110 |
-
return prepared_prompt
|
111 |
-
|
112 |
-
@spaces.GPU()
|
113 |
-
def main(content_b_lora, style_b_lora, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, progress=gr.Progress(track_tqdm=True)):
|
114 |
-
|
115 |
-
if randomize_seed:
|
116 |
-
seed = random.randint(0, MAX_SEED)
|
117 |
-
|
118 |
-
generator = torch.Generator().manual_seed(seed)
|
119 |
|
|
|
|
|
120 |
if content_b_lora is None:
|
121 |
content_B_LoRA_path = ''
|
122 |
else:
|
@@ -130,6 +122,17 @@ def main(content_b_lora, style_b_lora, prompt, negative_prompt, seed, randomize_
|
|
130 |
content_alpha,style_alpha = 1,1.1
|
131 |
|
132 |
load_b_lora_to_unet(pipeline, content_B_LoRA_path, style_B_LoRA_path, content_alpha, style_alpha)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
prompt = prompt
|
134 |
image = pipeline(
|
135 |
prompt,
|
@@ -139,8 +142,6 @@ def main(content_b_lora, style_b_lora, prompt, negative_prompt, seed, randomize_
|
|
139 |
height = height,
|
140 |
).images[0]
|
141 |
|
142 |
-
pipeline.unload_lora_weights()
|
143 |
-
|
144 |
return image
|
145 |
|
146 |
css="""
|
@@ -255,7 +256,7 @@ with gr.Blocks(css=css) as demo:
|
|
255 |
|
256 |
run_button.click(
|
257 |
fn = main,
|
258 |
-
inputs = [
|
259 |
outputs = [result]
|
260 |
)
|
261 |
|
|
|
106 |
style_model_instance_prompt = ''
|
107 |
|
108 |
prepared_prompt = f"{content_model_instance_prompt} {style_model_instance_prompt}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
pipeline.unload_lora_weights()
|
111 |
+
|
112 |
if content_b_lora is None:
|
113 |
content_B_LoRA_path = ''
|
114 |
else:
|
|
|
122 |
content_alpha,style_alpha = 1,1.1
|
123 |
|
124 |
load_b_lora_to_unet(pipeline, content_B_LoRA_path, style_B_LoRA_path, content_alpha, style_alpha)
|
125 |
+
|
126 |
+
return prepared_prompt
|
127 |
+
|
128 |
+
@spaces.GPU()
|
129 |
+
def main(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, progress=gr.Progress(track_tqdm=True)):
|
130 |
+
|
131 |
+
if randomize_seed:
|
132 |
+
seed = random.randint(0, MAX_SEED)
|
133 |
+
|
134 |
+
generator = torch.Generator().manual_seed(seed)
|
135 |
+
|
136 |
prompt = prompt
|
137 |
image = pipeline(
|
138 |
prompt,
|
|
|
142 |
height = height,
|
143 |
).images[0]
|
144 |
|
|
|
|
|
145 |
return image
|
146 |
|
147 |
css="""
|
|
|
256 |
|
257 |
run_button.click(
|
258 |
fn = main,
|
259 |
+
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
260 |
outputs = [result]
|
261 |
)
|
262 |
|