ford442 commited on
Commit
542ecc1
·
verified ·
1 Parent(s): 1e0ea77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -53,7 +53,7 @@ torch_dtype = torch.bfloat16
53
 
54
  checkpoint = "microsoft/Phi-3.5-mini-instruct"
55
  #vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
56
- vae = AutoencoderKL.from_pretrained("ford442/sdxl-vae-bf16", torch_dtype=torch.bfloat16)
57
 
58
  pipe = StableDiffusion3Pipeline.from_pretrained("ford442/stable-diffusion-3.5-medium-bf16", torch_dtype=torch.bfloat16)
59
  #pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium", token=hftoken, torch_dtype=torch.float32, device_map='balanced')
@@ -139,15 +139,16 @@ def infer(
139
  print('-- filtered prompt --')
140
  print(enhanced_prompt)
141
  print('-- generating image --')
142
- sd_image = pipe(
143
- prompt=enhanced_prompt, # This conversion is fine
144
- negative_prompt=negative_prompt,
145
- guidance_scale=guidance_scale,
146
- num_inference_steps=num_inference_steps,
147
- width=width,
148
- height=height,
149
- generator=generator
150
- ).images[0]
 
151
  print('-- got image --')
152
  image_path = f"sd35m_{seed}.png"
153
  sd_image.save(image_path,optimize=False,compress_level=0)
 
53
 
54
  checkpoint = "microsoft/Phi-3.5-mini-instruct"
55
  #vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
56
+ #vae = AutoencoderKL.from_pretrained("ford442/sdxl-vae-bf16", torch_dtype=torch.bfloat16)
57
 
58
  pipe = StableDiffusion3Pipeline.from_pretrained("ford442/stable-diffusion-3.5-medium-bf16", torch_dtype=torch.bfloat16)
59
  #pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium", token=hftoken, torch_dtype=torch.float32, device_map='balanced')
 
139
  print('-- filtered prompt --')
140
  print(enhanced_prompt)
141
  print('-- generating image --')
142
+ with torch.no_grad():
143
+ sd_image = pipe(
144
+ prompt=enhanced_prompt, # This conversion is fine
145
+ negative_prompt=negative_prompt,
146
+ guidance_scale=guidance_scale,
147
+ num_inference_steps=num_inference_steps,
148
+ width=width,
149
+ height=height,
150
+ generator=generator
151
+ ).images[0]
152
  print('-- got image --')
153
  image_path = f"sd35m_{seed}.png"
154
  sd_image.save(image_path,optimize=False,compress_level=0)