lllyasviel commited on
Commit
33adbe7
·
1 Parent(s): 3ca8852
Files changed (1) hide show
  1. webui.py +14 -24
webui.py CHANGED
@@ -1,30 +1,20 @@
1
- import os
2
- import modules.core as core
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
- xl_base = core.load_model(xl_base_filename)
 
 
 
 
 
 
 
 
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
- empty_latent = core.generate_empty_latent(width=1024, height=1024, batch_size=1)
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()