Commit
·
2d82e67
1
Parent(s):
cbc8ee5
long()
Browse files
app.py
CHANGED
@@ -8,11 +8,11 @@ import gradio as gr
|
|
8 |
#from IPython.display import display
|
9 |
|
10 |
tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=torch.float16)
|
11 |
-
text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=torch.float16)
|
12 |
|
13 |
# Here we use a different VAE to the original release, which has been fine-tuned for more steps
|
14 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-ema", torch_dtype=torch.float16)
|
15 |
-
unet = UNet2DConditionModel.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="unet", torch_dtype=torch.float16)
|
16 |
|
17 |
beta_start,beta_end = 0.00085,0.012
|
18 |
height = 512
|
@@ -27,7 +27,7 @@ scheduler = LMSDiscreteScheduler(beta_start=beta_start, beta_end=beta_end, beta_
|
|
27 |
def text_enc(prompts, maxlen=None):
|
28 |
if maxlen is None: maxlen = tokenizer.model_max_length
|
29 |
inp = tokenizer(prompts, padding="max_length", max_length=maxlen, truncation=True, return_tensors="pt")
|
30 |
-
return text_encoder(inp.input_ids.
|
31 |
|
32 |
def do_both(prompts):
|
33 |
def mk_img(t):
|
|
|
8 |
#from IPython.display import display
|
9 |
|
10 |
tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=torch.float16)
|
11 |
+
text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=torch.float16)
|
12 |
|
13 |
# Here we use a different VAE to the original release, which has been fine-tuned for more steps
|
14 |
+
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-ema", torch_dtype=torch.float16)
|
15 |
+
unet = UNet2DConditionModel.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="unet", torch_dtype=torch.float16)
|
16 |
|
17 |
beta_start,beta_end = 0.00085,0.012
|
18 |
height = 512
|
|
|
27 |
def text_enc(prompts, maxlen=None):
|
28 |
if maxlen is None: maxlen = tokenizer.model_max_length
|
29 |
inp = tokenizer(prompts, padding="max_length", max_length=maxlen, truncation=True, return_tensors="pt")
|
30 |
+
return text_encoder(inp.input_ids.long())[0]
|
31 |
|
32 |
def do_both(prompts):
|
33 |
def mk_img(t):
|