File size: 806 Bytes
8a6fc44
 
cefc456
8a6fc44
 
 
cefc456
8a6fc44
 
cefc456
 
 
8a6fc44
cefc456
 
8a6fc44
 
cefc456
8a6fc44
cefc456
 
 
 
 
 
 
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
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_with_stylization(prompt, style):
    input_prompt = prompt
    generated_image = pipeline.diffuse_text(input_prompt, stylize=True, style_prompt=style)

    img = Image.fromarray(generated_image)
    return img

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

gr.Interface(
    fn=generate_image_with_stylization, 
    inputs=["text", gr.inputs.Textbox(label="Style")], 
    outputs="image", 
    title=title, 
    description=description
).launch()