Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,7 @@ from diffusers import EulerDiscreteScheduler
|
|
17 |
from PIL import Image, ImageDraw, ImageFont
|
18 |
import os
|
19 |
|
|
|
20 |
device = "cuda"
|
21 |
ckpt_dir = snapshot_download(repo_id="Kwai-Kolors/Kolors")
|
22 |
ckpt_dir_canny = snapshot_download(repo_id="Kwai-Kolors/Kolors-ControlNet-Canny")
|
@@ -111,8 +112,9 @@ def text_to_image(text, size=72, position="middle-center"):
|
|
111 |
|
112 |
return image
|
113 |
|
|
|
114 |
@spaces.GPU
|
115 |
-
def infer_canny(prompt,
|
116 |
negative_prompt = "nsfw, facial shadows, low resolution, jpeg artifacts, blurry, bad quality, dark face, neon lights",
|
117 |
seed = 397886929,
|
118 |
randomize_seed = False,
|
@@ -130,7 +132,7 @@ def infer_canny(prompt,
|
|
130 |
generator = torch.Generator().manual_seed(seed)
|
131 |
|
132 |
# Generate text image
|
133 |
-
init_image = text_to_image(
|
134 |
init_image = resize_image(init_image, MAX_IMAGE_SIZE)
|
135 |
|
136 |
pipe = pipe_canny.to("cuda")
|
@@ -165,6 +167,12 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as Kolors:
|
|
165 |
placeholder="Enter your prompt",
|
166 |
lines=2
|
167 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
with gr.Accordion("Advanced Settings", open=False):
|
169 |
negative_prompt = gr.Textbox(
|
170 |
label="Negative prompt",
|
@@ -227,8 +235,8 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as Kolors:
|
|
227 |
|
228 |
canny_button.click(
|
229 |
fn = infer_canny,
|
230 |
-
inputs = [prompt, negative_prompt, seed, randomize_seed, guidance_scale, num_inference_steps, controlnet_conditioning_scale, control_guidance_end, strength],
|
231 |
outputs = [result, seed_used]
|
232 |
)
|
233 |
|
234 |
-
Kolors.queue().launch(debug=True)
|
|
|
17 |
from PIL import Image, ImageDraw, ImageFont
|
18 |
import os
|
19 |
|
20 |
+
|
21 |
device = "cuda"
|
22 |
ckpt_dir = snapshot_download(repo_id="Kwai-Kolors/Kolors")
|
23 |
ckpt_dir_canny = snapshot_download(repo_id="Kwai-Kolors/Kolors-ControlNet-Canny")
|
|
|
112 |
|
113 |
return image
|
114 |
|
115 |
+
|
116 |
@spaces.GPU
|
117 |
+
def infer_canny(prompt, text_for_image,
|
118 |
negative_prompt = "nsfw, facial shadows, low resolution, jpeg artifacts, blurry, bad quality, dark face, neon lights",
|
119 |
seed = 397886929,
|
120 |
randomize_seed = False,
|
|
|
132 |
generator = torch.Generator().manual_seed(seed)
|
133 |
|
134 |
# Generate text image
|
135 |
+
init_image = text_to_image(text_for_image)
|
136 |
init_image = resize_image(init_image, MAX_IMAGE_SIZE)
|
137 |
|
138 |
pipe = pipe_canny.to("cuda")
|
|
|
167 |
placeholder="Enter your prompt",
|
168 |
lines=2
|
169 |
)
|
170 |
+
with gr.Row():
|
171 |
+
text_for_image = gr.Textbox(
|
172 |
+
label="Text for Image Generation",
|
173 |
+
placeholder="Enter text to be converted into an image",
|
174 |
+
lines=3
|
175 |
+
)
|
176 |
with gr.Accordion("Advanced Settings", open=False):
|
177 |
negative_prompt = gr.Textbox(
|
178 |
label="Negative prompt",
|
|
|
235 |
|
236 |
canny_button.click(
|
237 |
fn = infer_canny,
|
238 |
+
inputs = [prompt, text_for_image, negative_prompt, seed, randomize_seed, guidance_scale, num_inference_steps, controlnet_conditioning_scale, control_guidance_end, strength],
|
239 |
outputs = [result, seed_used]
|
240 |
)
|
241 |
|
242 |
+
Kolors.queue().launch(debug=True)
|