File size: 2,123 Bytes
12aadac
 
8933eda
12aadac
8933eda
12aadac
 
 
 
 
 
 
 
 
 
 
 
 
22f10ca
12aadac
 
 
22f10ca
 
12aadac
 
 
 
 
 
 
 
 
22f10ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12aadac
 
22f10ca
12aadac
 
 
 
 
22f10ca
12aadac
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import gradio as gr
import spaces
from panna import SDXLTurboImg2Img

model = SDXLTurboImg2Img(device_name="cpu")
title = "# Stable Diffusion 2 XL Turbo Image2Image"
examples = [
    "A female model, high quality, fashion, Paris, Vogue, Maison Margiela, 8k",
]
css = """
#col-container {
    margin: 0 auto;
    max-width: 580px;
}
"""


@spaces.GPU
def infer(prompt, negative_prompt, image, noise_scale_latent_image, noise_scale_latent_prompt):
    return model(
        image=image,
        prompt=prompt,
        noise_scale_latent_image=noise_scale_latent_image,
        noise_scale_latent_prompt=noise_scale_latent_prompt,
        negative_prompt=negative_prompt,
        seed=42
    )


with gr.Blocks(css=css) as demo:
    with gr.Column(elem_id="col-container"):
        gr.Markdown(title)
        with gr.Row():
            prompt = gr.Text(
                label="Prompt", show_label=False, max_lines=1, placeholder="Enter your prompt", container=False
            )
        with gr.Row():
            negative_prompt = gr.Text(
                label="Negative Prompt", show_label=False, max_lines=1, placeholder="Enter a negative prompt", container=False, value="low quality, blurr",
            )
        with gr.Row():
            noise_scale_latent_image = gr.Slider(
                minimum=0, maximum=5, step=0.05, value=0, label='noise scale (latent image)'
            )
        with gr.Row():
            noise_scale_latent_prompt = gr.Slider(
                minimum=0, maximum=5, step=0.05, value=0, label='noise scale (latent prompt)'
            )
        with gr.Row():
            run_button = gr.Button("Run", scale=0)
        with gr.Row():
            image = gr.Image(label="Input Image", type='pil')
            result = gr.Image(label="Result", show_label=False)
        gr.Examples(examples=examples, inputs=[prompt])
    gr.on(
        triggers=[run_button.click, prompt.submit, negative_prompt.submit],
        fn=infer,
        inputs=[prompt, negative_prompt, image, noise_scale_latent_image, noise_scale_latent_prompt],
        outputs=[result]
    )
demo.launch(server_name="0.0.0.0")