Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,15 @@ with gr.Blocks() as demo:
|
|
121 |
|
122 |
if __name__ == "__main__":
|
123 |
# Check if CUDA is available
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|