LTT commited on
Commit
cf3bd8a
·
verified ·
1 Parent(s): 8e9a1c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -96,15 +96,15 @@ isomer_color_weights = torch.from_numpy(np.array([1, 0.5, 1, 0.5])).float().to(d
96
 
97
  # model initialization and loading
98
  # flux
99
- taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=torch.bfloat16).to(device_0)
100
- good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16, token=access_token).to(device_0)
101
- # flux_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16, token=access_token).to(device=device_0, dtype=torch.bfloat16)
102
- flux_pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16, vae=taef1, token=access_token).to(device_0)
103
  flux_lora_ckpt_path = hf_hub_download(repo_id="LTT/xxx-ckpt", filename="rgb_normal_large.safetensors", repo_type="model", token=access_token)
104
  flux_pipe.load_lora_weights(flux_lora_ckpt_path)
105
  flux_pipe.to(device=device_0, dtype=torch.bfloat16)
106
  torch.cuda.empty_cache()
107
- flux_pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(flux_pipe)
108
 
109
 
110
  # lrm
@@ -208,28 +208,28 @@ def generate_multi_view_images(prompt, seed):
208
  # generator = torch.manual_seed(seed)
209
  generator = torch.Generator().manual_seed(seed)
210
  with torch.no_grad():
211
- # images = flux_pipe(
212
- # prompt=prompt,
213
- # num_inference_steps=10,
214
- # guidance_scale=3.5,
215
- # num_images_per_prompt=1,
216
- # width=resolution * 4,
217
- # height=resolution * 2,
218
- # output_type='np',
219
- # generator=generator,
220
- # good_vae=good_vae,
221
- # ).images
222
- for img in flux_pipe.flux_pipe_call_that_returns_an_iterable_of_images(
223
  prompt=prompt,
 
224
  guidance_scale=3.5,
225
- num_inference_steps=4,
226
  width=resolution * 4,
227
  height=resolution * 2,
 
228
  generator=generator,
229
- output_type="np",
230
  good_vae=good_vae,
231
- ):
232
- pass
 
 
 
 
 
 
 
 
 
 
233
  # 返回最终的图像和种子(通过外部调用处理)
234
  return img
235
 
 
96
 
97
  # model initialization and loading
98
  # flux
99
+ # taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=torch.bfloat16).to(device_0)
100
+ # good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16, token=access_token).to(device_0)
101
+ flux_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16, token=access_token).to(device=device_0, dtype=torch.bfloat16)
102
+ # flux_pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16, vae=taef1, token=access_token).to(device_0)
103
  flux_lora_ckpt_path = hf_hub_download(repo_id="LTT/xxx-ckpt", filename="rgb_normal_large.safetensors", repo_type="model", token=access_token)
104
  flux_pipe.load_lora_weights(flux_lora_ckpt_path)
105
  flux_pipe.to(device=device_0, dtype=torch.bfloat16)
106
  torch.cuda.empty_cache()
107
+ # flux_pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(flux_pipe)
108
 
109
 
110
  # lrm
 
208
  # generator = torch.manual_seed(seed)
209
  generator = torch.Generator().manual_seed(seed)
210
  with torch.no_grad():
211
+ images = flux_pipe(
 
 
 
 
 
 
 
 
 
 
 
212
  prompt=prompt,
213
+ num_inference_steps=5,
214
  guidance_scale=3.5,
215
+ num_images_per_prompt=1,
216
  width=resolution * 4,
217
  height=resolution * 2,
218
+ output_type='np',
219
  generator=generator,
 
220
  good_vae=good_vae,
221
+ ).images
222
+ # for img in flux_pipe.flux_pipe_call_that_returns_an_iterable_of_images(
223
+ # prompt=prompt,
224
+ # guidance_scale=3.5,
225
+ # num_inference_steps=4,
226
+ # width=resolution * 4,
227
+ # height=resolution * 2,
228
+ # generator=generator,
229
+ # output_type="np",
230
+ # good_vae=good_vae,
231
+ # ):
232
+ # pass
233
  # 返回最终的图像和种子(通过外部调用处理)
234
  return img
235