Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -35,10 +35,10 @@ print(device)
|
|
35 |
base_model = "black-forest-labs/FLUX.1-dev"
|
36 |
|
37 |
# load pipe
|
38 |
-
taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).
|
39 |
-
good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype).
|
40 |
|
41 |
-
txt2img_pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype).
|
42 |
txt2img_pipe.__class__.load_lora_into_transformer = classmethod(load_lora_into_transformer)
|
43 |
|
44 |
|
@@ -165,25 +165,21 @@ def run_lora(prompt, image_url, lora_strings_json, image_strength, cfg_scale, s
|
|
165 |
error_message = ""
|
166 |
try:
|
167 |
gr.Info("Start to generate images ...")
|
168 |
-
with calculateDuration(f"Make a new generator: {seed}"):
|
169 |
-
txt2img_pipe.to(device)
|
170 |
-
generator = torch.Generator(device=device).manual_seed(seed)
|
171 |
print(device)
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
except Exception as e:
|
188 |
error_message = str(e)
|
189 |
gr.Error(error_message)
|
|
|
35 |
base_model = "black-forest-labs/FLUX.1-dev"
|
36 |
|
37 |
# load pipe
|
38 |
+
taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
|
39 |
+
good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype).to(device)
|
40 |
|
41 |
+
txt2img_pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype).to(device)
|
42 |
txt2img_pipe.__class__.load_lora_into_transformer = classmethod(load_lora_into_transformer)
|
43 |
|
44 |
|
|
|
165 |
error_message = ""
|
166 |
try:
|
167 |
gr.Info("Start to generate images ...")
|
|
|
|
|
|
|
168 |
print(device)
|
169 |
+
# Generate image
|
170 |
+
txt2img_pipe.to(device)
|
171 |
+
generator = torch.Generator(device=device).manual_seed(seed)
|
172 |
+
joint_attention_kwargs = {"scale": 1}
|
173 |
+
final_image = txt2img_pipe(
|
174 |
+
prompt=prompt,
|
175 |
+
num_inference_steps=steps,
|
176 |
+
guidance_scale=cfg_scale,
|
177 |
+
width=width,
|
178 |
+
height=height,
|
179 |
+
max_sequence_length=512,
|
180 |
+
generator=generator,
|
181 |
+
joint_attention_kwargs=joint_attention_kwargs
|
182 |
+
).images[0]
|
|
|
183 |
except Exception as e:
|
184 |
error_message = str(e)
|
185 |
gr.Error(error_message)
|