jiuface commited on
Commit
74f4467
·
verified ·
1 Parent(s): 564e11f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -21
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).to_empty(device)
39
- good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype).to_empty(device)
40
 
41
- txt2img_pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype).to_empty(device)
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
- with calculateDuration("Generating image"):
173
- # Generate image
174
- txt2img_pipe.to(device)
175
- joint_attention_kwargs = {"scale": 1}
176
- final_image = txt2img_pipe(
177
- prompt=prompt,
178
- num_inference_steps=steps,
179
- guidance_scale=cfg_scale,
180
- width=width,
181
- height=height,
182
- max_sequence_length=512,
183
- generator=generator,
184
- joint_attention_kwargs=joint_attention_kwargs
185
- ).images[0]
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)