Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,7 @@ torch.backends.cudnn.deterministic = False
|
|
36 |
torch.backends.cudnn.benchmark = False
|
37 |
#torch.backends.cuda.preferred_blas_library="cublas"
|
38 |
#torch.backends.cuda.preferred_linalg_library="cusolver"
|
|
|
39 |
|
40 |
hftoken = os.getenv("HF_AUTH_TOKEN")
|
41 |
|
@@ -112,10 +113,10 @@ def infer_30(
|
|
112 |
num_inference_steps,
|
113 |
progress=gr.Progress(track_tqdm=True),
|
114 |
):
|
|
|
115 |
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
116 |
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
117 |
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
118 |
-
torch.set_float32_matmul_precision("highest")
|
119 |
seed = random.randint(0, MAX_SEED)
|
120 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
121 |
print('-- generating image --')
|
@@ -162,10 +163,10 @@ def infer_60(
|
|
162 |
num_inference_steps,
|
163 |
progress=gr.Progress(track_tqdm=True),
|
164 |
):
|
|
|
165 |
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
166 |
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
167 |
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
168 |
-
torch.set_float32_matmul_precision("highest")
|
169 |
seed = random.randint(0, MAX_SEED)
|
170 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
171 |
print('-- generating image --')
|
@@ -212,10 +213,10 @@ def infer_90(
|
|
212 |
num_inference_steps,
|
213 |
progress=gr.Progress(track_tqdm=True),
|
214 |
):
|
|
|
215 |
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
216 |
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
217 |
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
218 |
-
torch.set_float32_matmul_precision("highest")
|
219 |
seed = random.randint(0, MAX_SEED)
|
220 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
221 |
print('-- generating image --')
|
@@ -262,7 +263,10 @@ def infer_100(
|
|
262 |
num_inference_steps,
|
263 |
progress=gr.Progress(track_tqdm=True),
|
264 |
):
|
265 |
-
|
|
|
|
|
|
|
266 |
seed = random.randint(0, MAX_SEED)
|
267 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
268 |
print('-- generating image --')
|
|
|
36 |
torch.backends.cudnn.benchmark = False
|
37 |
#torch.backends.cuda.preferred_blas_library="cublas"
|
38 |
#torch.backends.cuda.preferred_linalg_library="cusolver"
|
39 |
+
torch.set_float32_matmul_precision("highest")
|
40 |
|
41 |
hftoken = os.getenv("HF_AUTH_TOKEN")
|
42 |
|
|
|
113 |
num_inference_steps,
|
114 |
progress=gr.Progress(track_tqdm=True),
|
115 |
):
|
116 |
+
pipe.vae.to('cpu')
|
117 |
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
118 |
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
119 |
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
|
|
120 |
seed = random.randint(0, MAX_SEED)
|
121 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
122 |
print('-- generating image --')
|
|
|
163 |
num_inference_steps,
|
164 |
progress=gr.Progress(track_tqdm=True),
|
165 |
):
|
166 |
+
pipe.vae.to('cpu')
|
167 |
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
168 |
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
169 |
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
|
|
170 |
seed = random.randint(0, MAX_SEED)
|
171 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
172 |
print('-- generating image --')
|
|
|
213 |
num_inference_steps,
|
214 |
progress=gr.Progress(track_tqdm=True),
|
215 |
):
|
216 |
+
pipe.vae.to('cpu')
|
217 |
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
218 |
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
219 |
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
|
|
220 |
seed = random.randint(0, MAX_SEED)
|
221 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
222 |
print('-- generating image --')
|
|
|
263 |
num_inference_steps,
|
264 |
progress=gr.Progress(track_tqdm=True),
|
265 |
):
|
266 |
+
pipe.vae.to('cpu')
|
267 |
+
pipe.text_encoder=text_encoder #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device=device, dtype=torch.bfloat16)
|
268 |
+
pipe.text_encoder_2=text_encoder_2 #CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device=device, dtype=torch.bfloat16)
|
269 |
+
pipe.text_encoder_3=text_encoder_3 #T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device=device, dtype=torch.bfloat16)
|
270 |
seed = random.randint(0, MAX_SEED)
|
271 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
272 |
print('-- generating image --')
|