File size: 1,052 Bytes
8a6fc44
 
cefc456
8a6fc44
 
 
cefc456
8a6fc44
 
d13ead9
cefc456
d13ead9
8a6fc44
cefc456
 
8a6fc44
d13ead9
 
 
 
 
 
 
 
8a6fc44
cefc456
d13ead9
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import gradio as gr
from diffusers import DiffusionPipeline
from PIL import Image
import io

pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
api_key = os.getenv("API_KEY")

def generate_image(prompt, style):
    input_prompt = prompt
    generated_image = pipeline(input_prompt)

    img = Image.fromarray(generated_image)
    return img

title = "Stable Diffusion XL"
description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model."

styles = {
    "background": "linear-gradient(to bottom, #33ccff, #ff99cc)",
    "color": "black",
    "font-family": "Arial, sans-serif"
}

gr.Interface(
    fn=generate_image,
    inputs=["text", gr.Textbox(label="Style")],
    outputs="image",
    title=title,
    description=description,
    examples=[["Astronaut riding a horse", ""]],
    theme="compact",
    layout="vertical",
    allow_flagging=False,
    flagging_dir=None,
    flagging_host=None,
    capture_session=True,
    css={"body": styles}
).launch()