Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -85,9 +85,9 @@ pipe = StableDiffusion3Pipeline.from_pretrained(
|
|
85 |
#torch_dtype=torch.bfloat16,
|
86 |
#use_safetensors=False,
|
87 |
)
|
88 |
-
text_encoder=CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(device
|
89 |
-
text_encoder_2=CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(device
|
90 |
-
text_encoder_3=T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(device
|
91 |
|
92 |
pipe.load_lora_weights("ford442/sdxl-vae-bf16", weight_name="LoRA/UltraReal.safetensors")
|
93 |
|
@@ -118,17 +118,11 @@ def infer_30(
|
|
118 |
torch.set_float32_matmul_precision("highest")
|
119 |
seed = random.randint(0, MAX_SEED)
|
120 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
121 |
-
input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids
|
122 |
-
max_length = 77
|
123 |
-
if input_ids.shape[1] > max_length:
|
124 |
-
input_ids = input_ids[:, :max_length]
|
125 |
-
input_ids = input_ids.to(device)
|
126 |
print('-- generating image --')
|
127 |
sd_image = pipe(
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
#prompt_3=prompt,
|
132 |
negative_prompt=negative_prompt_1,
|
133 |
negative_prompt_2=negative_prompt_2,
|
134 |
negative_prompt_3=negative_prompt_3,
|
@@ -174,17 +168,11 @@ def infer_60(
|
|
174 |
torch.set_float32_matmul_precision("highest")
|
175 |
seed = random.randint(0, MAX_SEED)
|
176 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
177 |
-
input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids
|
178 |
-
max_length = 77
|
179 |
-
if input_ids.shape[1] > max_length:
|
180 |
-
input_ids = input_ids[:, :max_length]
|
181 |
-
input_ids = input_ids.to(device)
|
182 |
print('-- generating image --')
|
183 |
sd_image = pipe(
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
#prompt_3=prompt,
|
188 |
negative_prompt=negative_prompt_1,
|
189 |
negative_prompt_2=negative_prompt_2,
|
190 |
negative_prompt_3=negative_prompt_3,
|
@@ -230,17 +218,11 @@ def infer_90(
|
|
230 |
torch.set_float32_matmul_precision("highest")
|
231 |
seed = random.randint(0, MAX_SEED)
|
232 |
generator = torch.Generator(device='cuda').manual_seed(seed)
|
233 |
-
input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids
|
234 |
-
max_length = 77
|
235 |
-
if input_ids.shape[1] > max_length:
|
236 |
-
input_ids = input_ids[:, :max_length]
|
237 |
-
input_ids = input_ids.to(device)
|
238 |
print('-- generating image --')
|
239 |
sd_image = pipe(
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
#prompt_3=prompt,
|
244 |
negative_prompt=negative_prompt_1,
|
245 |
negative_prompt_2=negative_prompt_2,
|
246 |
negative_prompt_3=negative_prompt_3,
|
|
|
85 |
#torch_dtype=torch.bfloat16,
|
86 |
#use_safetensors=False,
|
87 |
)
|
88 |
+
text_encoder=CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder', token=True).to(torch.device("cuda:0", dtype=torch.bfloat16)
|
89 |
+
text_encoder_2=CLIPTextModelWithProjection.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_2',token=True).to(torch.device("cuda:0", dtype=torch.bfloat16)
|
90 |
+
text_encoder_3=T5EncoderModel.from_pretrained("ford442/stable-diffusion-3.5-large-bf16", subfolder='text_encoder_3',token=True).to(torch.device("cuda:0", dtype=torch.bfloat16)
|
91 |
|
92 |
pipe.load_lora_weights("ford442/sdxl-vae-bf16", weight_name="LoRA/UltraReal.safetensors")
|
93 |
|
|
|
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 --')
|
122 |
sd_image = pipe(
|
123 |
+
prompt=prompt,
|
124 |
+
prompt_2=prompt,
|
125 |
+
prompt_3=prompt,
|
|
|
126 |
negative_prompt=negative_prompt_1,
|
127 |
negative_prompt_2=negative_prompt_2,
|
128 |
negative_prompt_3=negative_prompt_3,
|
|
|
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 --')
|
172 |
sd_image = pipe(
|
173 |
+
prompt=prompt,
|
174 |
+
prompt_2=prompt,
|
175 |
+
prompt_3=prompt,
|
|
|
176 |
negative_prompt=negative_prompt_1,
|
177 |
negative_prompt_2=negative_prompt_2,
|
178 |
negative_prompt_3=negative_prompt_3,
|
|
|
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 --')
|
222 |
sd_image = pipe(
|
223 |
+
prompt=prompt,
|
224 |
+
prompt_2=prompt,
|
225 |
+
prompt_3=prompt,
|
|
|
226 |
negative_prompt=negative_prompt_1,
|
227 |
negative_prompt_2=negative_prompt_2,
|
228 |
negative_prompt_3=negative_prompt_3,
|