Spaces:
Paused
Paused
lllyasviel
commited on
Commit
·
33adbe7
1
Parent(s):
3ca8852
webui.py
CHANGED
@@ -1,30 +1,20 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
|
4 |
-
from modules.path import modelfile_path
|
5 |
|
|
|
|
|
6 |
|
7 |
-
xl_base_filename = os.path.join(modelfile_path, 'sd_xl_base_1.0.safetensors')
|
8 |
-
xl_refiner_filename = os.path.join(modelfile_path, 'sd_xl_refiner_1.0.safetensors')
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
positive_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt='a beautiful woman in forest')
|
13 |
-
negative_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt='bad, ugly')
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
sampled_latent = core.ksample(
|
18 |
-
unet=xl_base.unet,
|
19 |
-
positive_condition=positive_conditions,
|
20 |
-
negative_condition=negative_conditions,
|
21 |
-
latent_image=empty_latent
|
22 |
-
)
|
23 |
-
|
24 |
-
decoded_latent = core.decode_vae(vae=xl_base.vae, latent_image=sampled_latent)
|
25 |
-
|
26 |
-
images = core.image_to_numpy(decoded_latent)
|
27 |
-
|
28 |
-
for image in images:
|
29 |
-
import cv2
|
30 |
-
cv2.imwrite('a.png', image[:, :, ::-1])
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from modules.default_pipeline import process
|
3 |
|
|
|
4 |
|
5 |
+
def generate_clicked(positive_prompt):
|
6 |
+
return process(positive_prompt=positive_prompt, negative_prompt='bad, ugly')
|
7 |
|
|
|
|
|
8 |
|
9 |
+
block = gr.Blocks().queue()
|
10 |
+
with block:
|
11 |
+
with gr.Row():
|
12 |
+
with gr.Column():
|
13 |
+
prompt = gr.Textbox(label="Prompt", value='a handsome man in forest')
|
14 |
+
run_button = gr.Button(label="Run")
|
15 |
+
with gr.Column():
|
16 |
+
result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2, height='auto')
|
17 |
+
run_button.click(fn=generate_clicked, inputs=[prompt], outputs=[result_gallery])
|
18 |
|
|
|
|
|
19 |
|
20 |
+
block.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|