Kvikontent commited on
Commit
d13ead9
Β·
verified Β·
1 Parent(s): 642d3eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -7,20 +7,34 @@ import io
7
  pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
8
  api_key = os.getenv("API_KEY")
9
 
10
- def generate_image_with_stylization(prompt, style):
11
  input_prompt = prompt
12
- generated_image = pipeline.diffuse_text(input_prompt, stylize=True, style_prompt=style)
13
 
14
  img = Image.fromarray(generated_image)
15
  return img
16
 
17
- title = "Stable Fiddusion XL"
18
- description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model, applying stylization."
 
 
 
 
 
 
19
 
20
  gr.Interface(
21
- fn=generate_image_with_stylization,
22
- inputs=["text", gr.inputs.Textbox(label="Style")],
23
- outputs="image",
24
- title=title,
25
- description=description
26
- ).launch()
 
 
 
 
 
 
 
 
 
7
  pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
8
  api_key = os.getenv("API_KEY")
9
 
10
+ def generate_image(prompt, style):
11
  input_prompt = prompt
12
+ generated_image = pipeline(input_prompt)
13
 
14
  img = Image.fromarray(generated_image)
15
  return img
16
 
17
+ title = "Stable Diffusion XL"
18
+ description = "This app generates an image based on the provided prompt using the Stable Diffusion XL model."
19
+
20
+ styles = {
21
+ "background": "linear-gradient(to bottom, #33ccff, #ff99cc)",
22
+ "color": "black",
23
+ "font-family": "Arial, sans-serif"
24
+ }
25
 
26
  gr.Interface(
27
+ fn=generate_image,
28
+ inputs=["text", gr.Textbox(label="Style")],
29
+ outputs="image",
30
+ title=title,
31
+ description=description,
32
+ examples=[["Astronaut riding a horse", ""]],
33
+ theme="compact",
34
+ layout="vertical",
35
+ allow_flagging=False,
36
+ flagging_dir=None,
37
+ flagging_host=None,
38
+ capture_session=True,
39
+ css={"body": styles}
40
+ ).launch()