nyanko7 commited on
Commit
a02d101
1 Parent(s): dc8029f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -760,8 +760,8 @@ def generate_image(
760
  if seed == 0:
761
  seed = int(random.random() * 1000000)
762
 
763
- device = "cuda" if torch.cuda.is_available() else "cpu"
764
- torch_device = torch.device(device)
765
 
766
  global model, model_zero_init
767
  if not model_zero_init:
@@ -792,8 +792,9 @@ def generate_image(
792
  timesteps = timesteps[t_idx:]
793
  x = t * x + (1.0 - t) * init_image.to(x.dtype)
794
 
795
- inp = prepare(t5=t5, clip=clip, img=x, prompt=prompt)
796
- x = denoise(model, **inp, timesteps=timesteps, guidance=guidance)
 
797
 
798
  # with profile(activities=[ProfilerActivity.CPU],record_shapes=True,profile_memory=True) as prof:
799
  # print(prof.key_averages().table(sort_by="cpu_time_total", row_limit=20))
 
760
  if seed == 0:
761
  seed = int(random.random() * 1000000)
762
 
763
+ assert torch.cuda.is_available()
764
+ torch_device = torch.device("cuda")
765
 
766
  global model, model_zero_init
767
  if not model_zero_init:
 
792
  timesteps = timesteps[t_idx:]
793
  x = t * x + (1.0 - t) * init_image.to(x.dtype)
794
 
795
+ with torch_device:
796
+ inp = prepare(t5=t5, clip=clip, img=x, prompt=prompt)
797
+ x = denoise(model, **inp, timesteps=timesteps, guidance=guidance)
798
 
799
  # with profile(activities=[ProfilerActivity.CPU],record_shapes=True,profile_memory=True) as prof:
800
  # print(prof.key_averages().table(sort_by="cpu_time_total", row_limit=20))