Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -157,6 +157,8 @@ import gradio as gr
|
|
157 |
import numpy as np
|
158 |
from PIL import Image
|
159 |
|
|
|
|
|
160 |
#import diffusers
|
161 |
from diffusers import AutoencoderKL, StableDiffusionXLPipeline
|
162 |
from diffusers import EulerAncestralDiscreteScheduler
|
@@ -175,6 +177,8 @@ os.putenv('HF_HUB_ENABLE_HF_TRANSFER','1')
|
|
175 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
176 |
os.environ["SAFETENSORS_FAST_GPU"] = "1"
|
177 |
|
|
|
|
|
178 |
upscaler = UpscaleWithModel.from_pretrained("Kim2091/ClearRealityV1").to(torch.device("cuda:0"))
|
179 |
|
180 |
def load_and_prepare_model():
|
@@ -198,7 +202,8 @@ def load_and_prepare_model():
|
|
198 |
print(f'init noise scale: {pipe.scheduler.init_noise_sigma}')
|
199 |
pipe.watermark=None
|
200 |
pipe.safety_checker=None
|
201 |
-
pipe.to(torch.device('cuda:0'), torch.bfloat16)
|
|
|
202 |
|
203 |
return pipe
|
204 |
|
|
|
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
|
164 |
from diffusers import EulerAncestralDiscreteScheduler
|
|
|
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 |
|
184 |
def load_and_prepare_model():
|
|
|
202 |
print(f'init noise scale: {pipe.scheduler.init_noise_sigma}')
|
203 |
pipe.watermark=None
|
204 |
pipe.safety_checker=None
|
205 |
+
#pipe.to(torch.device('cuda:0'), torch.bfloat16)
|
206 |
+
pipe.to(accelerator.device)
|
207 |
|
208 |
return pipe
|
209 |
|