gokaygokay
commited on
Commit
•
90da0e7
1
Parent(s):
f03bfaf
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os, torch, random
|
|
|
2 |
from kolors.pipelines.pipeline_stable_diffusion_xl_chatglm_256 import StableDiffusionXLPipeline
|
3 |
from kolors.models.modeling_chatglm import ChatGLMModel
|
4 |
from kolors.models.tokenization_chatglm import ChatGLMTokenizer
|
@@ -6,14 +7,18 @@ from diffusers import UNet2DConditionModel, AutoencoderKL
|
|
6 |
from diffusers import EulerDiscreteScheduler
|
7 |
import gradio as gr
|
8 |
|
9 |
-
|
|
|
|
|
|
|
10 |
text_encoder = ChatGLMModel.from_pretrained(
|
11 |
-
|
12 |
torch_dtype=torch.float16).half()
|
13 |
-
tokenizer = ChatGLMTokenizer.from_pretrained(
|
14 |
-
vae = AutoencoderKL.from_pretrained(
|
15 |
-
scheduler = EulerDiscreteScheduler.from_pretrained(
|
16 |
-
unet = UNet2DConditionModel.from_pretrained(
|
|
|
17 |
pipe = StableDiffusionXLPipeline(
|
18 |
vae=vae,
|
19 |
text_encoder=text_encoder,
|
@@ -55,4 +60,4 @@ iface = gr.Interface(
|
|
55 |
description="Generate images using the Kolors Stable Diffusion XL model."
|
56 |
)
|
57 |
|
58 |
-
iface.launch()
|
|
|
1 |
import os, torch, random
|
2 |
+
from huggingface_hub import snapshot_download
|
3 |
from kolors.pipelines.pipeline_stable_diffusion_xl_chatglm_256 import StableDiffusionXLPipeline
|
4 |
from kolors.models.modeling_chatglm import ChatGLMModel
|
5 |
from kolors.models.tokenization_chatglm import ChatGLMTokenizer
|
|
|
7 |
from diffusers import EulerDiscreteScheduler
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# Download the model files
|
11 |
+
ckpt_dir = snapshot_download(repo_id="Kwai-Kolors/Kolors")
|
12 |
+
|
13 |
+
# Load the models
|
14 |
text_encoder = ChatGLMModel.from_pretrained(
|
15 |
+
os.path.join(ckpt_dir, 'text_encoder'),
|
16 |
torch_dtype=torch.float16).half()
|
17 |
+
tokenizer = ChatGLMTokenizer.from_pretrained(os.path.join(ckpt_dir, 'text_encoder'))
|
18 |
+
vae = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir, "vae"), revision=None).half()
|
19 |
+
scheduler = EulerDiscreteScheduler.from_pretrained(os.path.join(ckpt_dir, "scheduler"))
|
20 |
+
unet = UNet2DConditionModel.from_pretrained(os.path.join(ckpt_dir, "unet"), revision=None).half()
|
21 |
+
|
22 |
pipe = StableDiffusionXLPipeline(
|
23 |
vae=vae,
|
24 |
text_encoder=text_encoder,
|
|
|
60 |
description="Generate images using the Kolors Stable Diffusion XL model."
|
61 |
)
|
62 |
|
63 |
+
iface.launch(debug=True)
|