Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import numpy as np
|
|
4 |
import spaces
|
5 |
import torch
|
6 |
from diffusers import AutoPipelineForText2Image, AutoencoderKL #,EulerDiscreteScheduler
|
7 |
-
from
|
8 |
|
9 |
if not torch.cuda.is_available():
|
10 |
DESCRIPTION += "\n<p>你现在运行在CPU上 但是只支持GPU.</p>"
|
@@ -45,15 +45,13 @@ def infer(
|
|
45 |
):
|
46 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
47 |
generator = torch.Generator().manual_seed(seed)
|
|
|
|
|
48 |
|
49 |
-
(prompt_embeds, prompt_neg_embeds, pooled_prompt_embeds, negative_pooled_prompt_embeds) = get_weighted_text_embeddings_sdxl(pipe, prompt = prompt, neg_prompt = negative_prompt)
|
50 |
image = pipe(
|
51 |
-
prompt_embeds = prompt_embeds,
|
52 |
-
negative_prompt_embeds = prompt_neg_embeds,
|
53 |
-
pooled_prompt_embeds = pooled_prompt_embeds,
|
54 |
-
negative_pooled_prompt_embeds = negative_pooled_prompt_embeds,
|
55 |
#prompt=prompt,
|
56 |
-
|
|
|
57 |
width=width,
|
58 |
height=height,
|
59 |
guidance_scale=guidance_scale,
|
|
|
4 |
import spaces
|
5 |
import torch
|
6 |
from diffusers import AutoPipelineForText2Image, AutoencoderKL #,EulerDiscreteScheduler
|
7 |
+
from compel import Compel, ReturnedEmbeddingsType
|
8 |
|
9 |
if not torch.cuda.is_available():
|
10 |
DESCRIPTION += "\n<p>你现在运行在CPU上 但是只支持GPU.</p>"
|
|
|
45 |
):
|
46 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
47 |
generator = torch.Generator().manual_seed(seed)
|
48 |
+
compel = Compel(tokenizer=pipeline.tokenizer, text_encoder=pipeline.text_encoder)
|
49 |
+
conditioning = compel.build_conditioning_tensor(prompt)
|
50 |
|
|
|
51 |
image = pipe(
|
|
|
|
|
|
|
|
|
52 |
#prompt=prompt,
|
53 |
+
prompt_embeds=conditioning,
|
54 |
+
negative_prompt=negative_prompt,
|
55 |
width=width,
|
56 |
height=height,
|
57 |
guidance_scale=guidance_scale,
|