-
Notifications
You must be signed in to change notification settings - Fork 0
/
gserver.py
45 lines (38 loc) · 1.12 KB
/
gserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
from core import sdxl_styles, generator
fd = generator.FastDiffusionGenerator()
def generate(
prompt,
negative_prompt,
style,
controlnet_conditioning_scale,
control_schema,
control_image,
):
fd.set_control_schema(control_schema)
if not fd.models_loaded:
fd.load_models()
fd.controlnet_conditioning_scale = controlnet_conditioning_scale
style = sdxl_styles.styles.get(style)
prompt = style[0].replace("{prompt}", prompt)
negative_prompt = negative_prompt + "," + style[1]
return fd.run(control_image, prompt, negative_prompt)
prompt = gr.Textbox(lines=3)
negative_prompt = gr.Textbox(lines=3)
style = gr.Dropdown(choices=sdxl_styles.style_keys)
control_schema = gr.Radio(["None", "canny", "depth"])
controlnet_conditioning_scale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, value=0.5)
control_image = gr.Image(type="pil")
demo = gr.Interface(
fn=generate,
inputs=[
prompt,
negative_prompt,
style,
controlnet_conditioning_scale,
control_schema,
control_image,
],
outputs="image",
)
demo.launch()