harpomaxx commited on
Commit
e306b09
·
verified ·
1 Parent(s): 89e5ee7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -121,7 +121,15 @@ with gr.Blocks() as demo:
121
 
122
  if __name__ == "__main__":
123
  # Check if CUDA is available
124
- device = "cuda" if torch.cuda.is_available() else "cpu"
125
- pipe = StableDiffusionPipeline.from_single_file(PATH,torch_dtype=torch.float16).to(device)
 
 
 
 
 
 
 
 
126
  demo.queue(concurrency_count=2,
127
  ).launch()
 
121
 
122
  if __name__ == "__main__":
123
  # Check if CUDA is available
124
+ if torch.cuda.is_available():
125
+ device = "cuda"
126
+ dtype = torch.float16 # Use float16 for GPU to save memory
127
+ else:
128
+ device = "cpu"
129
+ dtype = torch.float32 # CPU does not support float16, use float32 instead
130
+
131
+
132
+
133
+ pipe = StableDiffusionPipeline.from_single_file(PATH,torch_dtype=dtype).to(device)
134
  demo.queue(concurrency_count=2,
135
  ).launch()