ford442 commited on
Commit
ad5997b
·
verified ·
1 Parent(s): 53a73b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -157,7 +157,7 @@ import gradio as gr
157
  import numpy as np
158
  from PIL import Image
159
 
160
- from accelerate import Accelerator
161
 
162
  #import diffusers
163
  from diffusers import AutoencoderKL, StableDiffusionXLPipeline
@@ -177,7 +177,7 @@ os.putenv('HF_HUB_ENABLE_HF_TRANSFER','1')
177
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
178
  os.environ["SAFETENSORS_FAST_GPU"] = "1"
179
 
180
- accelerator = Accelerator(mixed_precision="bf16") # Example
181
 
182
  upscaler = UpscaleWithModel.from_pretrained("Kim2091/ClearRealityV1").to(torch.device("cuda:0"))
183
 
@@ -203,9 +203,9 @@ def load_and_prepare_model():
203
  print(f'init noise scale: {pipe.scheduler.init_noise_sigma}')
204
  pipe.watermark=None
205
  pipe.safety_checker=None
206
- #pipe.to(torch.device('cuda:0'), torch.bfloat16)
207
- pipe.to(torch.bfloat16)
208
- pipe.to(accelerator.device)
209
  return pipe
210
 
211
  #hidet.option.parallel_build(False)
@@ -273,8 +273,7 @@ def generate_30(
273
  filename = uploadNote(prompt,num_inference_steps,guidance_scale,timestamp)
274
  upload_to_ftp(filename)
275
  batch_options = options.copy()
276
- with accelerator.autocast():
277
- rv_image = pipe(**batch_options).images[0]
278
  sd_image_path = f"rv_C_{timestamp}.png"
279
  rv_image.save(sd_image_path,optimize=False,compress_level=0)
280
  upload_to_ftp(sd_image_path)
 
157
  import numpy as np
158
  from PIL import Image
159
 
160
+ #from accelerate import Accelerator
161
 
162
  #import diffusers
163
  from diffusers import AutoencoderKL, StableDiffusionXLPipeline
 
177
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
178
  os.environ["SAFETENSORS_FAST_GPU"] = "1"
179
 
180
+ #accelerator = Accelerator(mixed_precision="bf16") # Example
181
 
182
  upscaler = UpscaleWithModel.from_pretrained("Kim2091/ClearRealityV1").to(torch.device("cuda:0"))
183
 
 
203
  print(f'init noise scale: {pipe.scheduler.init_noise_sigma}')
204
  pipe.watermark=None
205
  pipe.safety_checker=None
206
+ pipe.to(torch.device('cuda:0'), torch.bfloat16)
207
+ #pipe.to(torch.bfloat16)
208
+ #pipe.to(accelerator.device)
209
  return pipe
210
 
211
  #hidet.option.parallel_build(False)
 
273
  filename = uploadNote(prompt,num_inference_steps,guidance_scale,timestamp)
274
  upload_to_ftp(filename)
275
  batch_options = options.copy()
276
+ rv_image = pipe(**batch_options).images[0]
 
277
  sd_image_path = f"rv_C_{timestamp}.png"
278
  rv_image.save(sd_image_path,optimize=False,compress_level=0)
279
  upload_to_ftp(sd_image_path)