cutycat2000x commited on
Commit
43b3166
1 Parent(s): 723dfb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +393 -109
app.py CHANGED
@@ -1,70 +1,312 @@
 
 
 
 
1
  import gradio as gr
2
  import numpy as np
3
- import random
4
- from diffusers import DiffusionPipeline
 
5
  import torch
 
6
 
7
- device = "cuda" if torch.cuda.is_available() else "cpu"
8
 
9
- if torch.cuda.is_available():
10
- torch.cuda.max_memory_allocated(device=device)
11
- pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
12
- pipe.enable_xformers_memory_efficient_attention()
13
- pipe = pipe.to(device)
14
- else:
15
- pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
16
- pipe = pipe.to(device)
17
 
18
- MAX_SEED = np.iinfo(np.int32).max
19
- MAX_IMAGE_SIZE = 1024
20
 
21
- def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
 
 
 
22
 
 
23
  if randomize_seed:
24
  seed = random.randint(0, MAX_SEED)
25
-
26
- generator = torch.Generator().manual_seed(seed)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- image = pipe(
29
- prompt = prompt,
30
- negative_prompt = negative_prompt,
31
- guidance_scale = guidance_scale,
32
- num_inference_steps = num_inference_steps,
33
- width = width,
34
- height = height,
35
- generator = generator
36
- ).images[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
- return image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  examples = [
41
- "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
42
- "An astronaut riding a green horse",
43
- "A delicious ceviche cheesecake slice",
 
44
  ]
45
 
46
- css="""
47
- #col-container {
48
- margin: 0 auto;
49
- max-width: 520px;
 
50
  }
51
- """
52
 
53
- if torch.cuda.is_available():
54
- power_device = "GPU"
55
- else:
56
- power_device = "CPU"
 
 
 
57
 
58
- with gr.Blocks(css=css) as demo:
59
-
60
- with gr.Column(elem_id="col-container"):
61
- gr.Markdown(f"""
62
- # Text-to-Image Gradio Template
63
- Currently running on {power_device}.
64
- """)
65
-
66
  with gr.Row():
67
-
68
  prompt = gr.Text(
69
  label="Prompt",
70
  show_label=False,
@@ -72,75 +314,117 @@ with gr.Blocks(css=css) as demo:
72
  placeholder="Enter your prompt",
73
  container=False,
74
  )
75
-
76
- run_button = gr.Button("Run", scale=0)
77
-
78
- result = gr.Image(label="Result", show_label=False)
79
-
80
- with gr.Accordion("Advanced Settings", open=False):
81
-
82
- negative_prompt = gr.Text(
83
  label="Negative prompt",
84
  max_lines=1,
85
  placeholder="Enter a negative prompt",
86
- visible=False,
87
  )
88
-
89
- seed = gr.Slider(
90
- label="Seed",
91
- minimum=0,
92
- maximum=MAX_SEED,
93
  step=1,
94
- value=0,
95
  )
96
-
97
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
98
-
99
- with gr.Row():
100
-
101
- width = gr.Slider(
102
- label="Width",
103
- minimum=256,
104
- maximum=MAX_IMAGE_SIZE,
105
- step=32,
106
- value=512,
107
- )
108
-
109
- height = gr.Slider(
110
- label="Height",
111
- minimum=256,
112
- maximum=MAX_IMAGE_SIZE,
113
- step=32,
114
- value=512,
115
- )
116
-
117
- with gr.Row():
118
-
119
- guidance_scale = gr.Slider(
120
- label="Guidance scale",
121
- minimum=0.0,
122
- maximum=10.0,
123
- step=0.1,
124
- value=0.0,
125
- )
126
-
127
- num_inference_steps = gr.Slider(
128
- label="Number of inference steps",
129
- minimum=1,
130
- maximum=12,
131
- step=1,
132
- value=2,
133
- )
134
-
135
- gr.Examples(
136
- examples = examples,
137
- inputs = [prompt]
138
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
- run_button.click(
141
- fn = infer,
142
- inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
143
- outputs = [result]
 
144
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
- demo.queue().launch()
 
 
1
+ #!/usr/bin/env python
2
+ import os
3
+ import random
4
+ import uuid
5
  import gradio as gr
6
  import numpy as np
7
+ from PIL import Image
8
+ import spaces
9
+ from typing import Tuple
10
  import torch
11
+ from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
12
 
 
13
 
14
+ DESCRIPTION = """# InterDiffusion-3.8"""
 
 
 
 
 
 
 
15
 
 
 
16
 
17
+ def save_image(img):
18
+ unique_name = str(uuid.uuid4()) + ".png"
19
+ img.save(unique_name)
20
+ return unique_name
21
 
22
+ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
23
  if randomize_seed:
24
  seed = random.randint(0, MAX_SEED)
25
+ return seed
26
+
27
+
28
+
29
+ MAX_SEED = np.iinfo(np.int32).max
30
+
31
+ if not torch.cuda.is_available():
32
+ DESCRIPTION += "\n<p>Running on CPU, This may not work on CPU.</p>"
33
+
34
+ MAX_SEED = np.iinfo(np.int32).max
35
+
36
+ USE_TORCH_COMPILE = 0
37
+ ENABLE_CPU_OFFLOAD = 0
38
+
39
+
40
+
41
+
42
+ if torch.cuda.is_available():
43
+ pipe = StableDiffusionXLPipeline.from_pretrained(
44
+ "cutycat2000x/InterDiffusion-3.8",
45
+ torch_dtype=torch.float16,
46
+ use_safetensors=True,
47
+ )
48
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
49
+ pipe.load_lora_weights("cutycat2000x/InterDiffusion-LoRA", weight_name="lora.safetensors", adapter_name="InterDiffusion-3.8")
50
+ pipe.set_adapters("InterDiffusion-3.8")
51
+ pipe.to("cuda")
52
+
53
+
54
+
55
+
56
+
57
+ style_list = [
58
+
59
+ {
60
+ "name": "Cinematic",
61
+ "prompt": "cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
62
+ "negative_prompt": "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",
63
+ },
64
+
65
+ {
66
+ "name": "8K",
67
+ "prompt": "hyper-realistic 8K image of {prompt} . ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
68
+ "negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, deformed, ugly",
69
+ },
70
 
71
+ {
72
+ "name": "4K",
73
+ "prompt": "hyper-realistic 4K image of {prompt} . ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
74
+ "negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, deformed, ugly",
75
+ },
76
+
77
+ {
78
+ "name": "HDR",
79
+ "prompt": "HDR photo of {prompt} . high dynamic range, vivid colors, sharp contrast, realistic, detailed, high resolution, professional",
80
+ "negative_prompt": "dull, low contrast, blurry, unrealistic, cartoonish, ugly, deformed",
81
+ },
82
+
83
+ {
84
+ "name": "Photographic",
85
+ "prompt": "cinematic photo {prompt} . 35mm photograph, film, bokeh, professional, 4k, highly detailed",
86
+ "negative_prompt": "drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly",
87
+ },
88
+
89
+ {
90
+ "name": "Disney Style",
91
+ "prompt": "Disney style cartoon of {prompt} . whimsical, colorful, expressive, magical, highly detailed, animated movie style, family-friendly",
92
+ "negative_prompt": "realistic, photographic, detailed textures, dark, scary, ugly, deformed",
93
+ },
94
+
95
+ {
96
+ "name": "Anime",
97
+ "prompt": "anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed",
98
+ "negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast",
99
+ },
100
+ {
101
+ "name": "Manga",
102
+ "prompt": "manga style {prompt} . vibrant, high-energy, detailed, iconic, Japanese comic style",
103
+ "negative_prompt": "ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, Western comic style",
104
+ },
105
+ {
106
+ "name": "Digital Art",
107
+ "prompt": "concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed",
108
+ "negative_prompt": "photo, photorealistic, realism, ugly",
109
+ },
110
+ {
111
+ "name": "Pixel art",
112
+ "prompt": "pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics",
113
+ "negative_prompt": "sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic",
114
+ },
115
+ {
116
+ "name": "Fantasy art",
117
+ "prompt": "ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy",
118
+ "negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
119
+ },
120
+
121
+ {
122
+ "name": "Cyberpunk",
123
+ "prompt": "cyberpunk style {prompt} . neon lights, futuristic, gritty, dark, highly detailed, urban, high contrast, high-tech, dystopian",
124
+ "negative_prompt": "natural, bright, cheerful, plain, simplistic, ugly, deformed",
125
+ },
126
+
127
+ {
128
+ "name": "Graffiti Art",
129
+ "prompt": "graffiti art of {prompt} . street art style, vibrant colors, bold lines, urban, edgy, highly detailed, spray paint texture",
130
+ "negative_prompt": "realistic, photographic, plain, clean, formal, ugly, deformed",
131
+ },
132
 
133
+ {
134
+ "name": "Neonpunk",
135
+ "prompt": "neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional",
136
+ "negative_prompt": "painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
137
+ },
138
+ {
139
+ "name": "3D Model",
140
+ "prompt": "professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting",
141
+ "negative_prompt": "ugly, deformed, noisy, low poly, blurry, painting",
142
+ },
143
+
144
+ {
145
+ "name": "Steampunk",
146
+ "prompt": "steampunk {prompt} . Victorian era, mechanical, gears, steam-powered, brass, intricate, detailed, retrofuturistic",
147
+ "negative_prompt": "modern, digital, plain, clean, simplistic, messy, ugly, deformed, low contrast",
148
+ },
149
+
150
+ {
151
+ "name": "Retro Futurism",
152
+ "prompt": "retro-futuristic {prompt} . 1960s sci-fi, sleek, bold colors, imaginative, space age, mid-century modern, detailed",
153
+ "negative_prompt": "realistic, modern, plain, clean, minimalist, messy, ugly, deformed",
154
+ },
155
+
156
+ {
157
+ "name": "Baroque",
158
+ "prompt": "baroque style {prompt} . ornate, dramatic, rich colors, contrast, grandeur, detailed, historical, 17th century",
159
+ "negative_prompt": "modern, plain, clean, minimalist, simplistic, ugly, deformed",
160
+ },
161
+
162
+ {
163
+ "name": "Surreal Art",
164
+ "prompt": "surreal art of {prompt} . dreamlike, abstract, otherworldly, bizarre, fantastical, imaginative, highly detailed, Salvador Dalí inspired",
165
+ "negative_prompt": "realistic, photographic, normal, plain, ordinary, ugly, deformed, low contrast",
166
+ },
167
+
168
+ {
169
+ "name": "Impressionist",
170
+ "prompt": "impressionist painting of {prompt} . vibrant, textured, brush strokes, light, movement, Monet inspired, painterly, colorful",
171
+ "negative_prompt": "realistic, photographic, detailed, digital, sharp, clean, cartoon, ugly, deformed",
172
+ },
173
+
174
+ {
175
+ "name": "Art Deco",
176
+ "prompt": "art deco style {prompt} . elegant, geometric, rich colors, decorative, 1920s, luxury, sophisticated, stylish, highly detailed",
177
+ "negative_prompt": "modern, plain, minimalist, messy, disorganized, ugly, deformed, low contrast",
178
+ },
179
+
180
+ {
181
+ "name": "Minimalist",
182
+ "prompt": "minimalist {prompt} . clean, simple, sparse, monochrome, elegant, subtle, understated, high contrast",
183
+ "negative_prompt": "detailed, busy, cluttered, colorful, messy, noisy, ugly, deformed",
184
+ },
185
+
186
+ {
187
+ "name": "Abstract",
188
+ "prompt": "abstract {prompt} . expressive, non-representational, bold colors, shapes, forms, textures, highly detailed, modern art",
189
+ "negative_prompt": "realistic, photographic, detailed, recognizable, plain, ugly, deformed",
190
+ },
191
+
192
+ {
193
+ "name": "Gothic",
194
+ "prompt": "gothic {prompt} . dark, eerie, ornate, medieval, mysterious, detailed, shadowy, dramatic, gothic architecture",
195
+ "negative_prompt": "bright, colorful, modern, plain, clean, minimalist, ugly, deformed",
196
+ },
197
+
198
+ {
199
+ "name": "Vaporwave",
200
+ "prompt": "vaporwave {prompt} . neon colors, 80s aesthetics, retro, synthwave, glitch art, nostalgic, surreal, highly detailed",
201
+ "negative_prompt": "modern, plain, realistic, clean, simple, ugly, deformed",
202
+ },
203
+
204
+ {
205
+ "name": "HDR Urban",
206
+ "prompt": "HDR urban scene of {prompt} . high dynamic range, vibrant, detailed, sharp contrast, cityscape, realistic, high resolution, professional",
207
+ "negative_prompt": "dull, low contrast, blurry, unrealistic, cartoonish, ugly, deformed",
208
+ },
209
+
210
+ {
211
+ "name": "Classic Oil Painting",
212
+ "prompt": "classic oil painting of {prompt} . rich textures, brush strokes, warm colors, realistic, traditional, highly detailed, canvas texture",
213
+ "negative_prompt": "photographic, modern, simplistic, digital, cartoonish, ugly, deformed",
214
+ },
215
+
216
+ {
217
+ "name": "HDR Nature",
218
+ "prompt": "HDR nature scene of {prompt} . high dynamic range, vivid colors, detailed, sharp contrast, realistic, high resolution, professional",
219
+ "negative_prompt": "dull, low contrast, blurry, unrealistic, cartoonish, ugly, deformed",
220
+ },
221
+
222
+ {
223
+ "name": "Modern Advertisement Logo",
224
+ "prompt": "high-resolution modern advertisement logo of {prompt} . sleek, minimalist, vibrant colors, clean lines, sharp, professional, eye-catching",
225
+ "negative_prompt": "vintage, messy, low resolution, blurry, dull, deformed, ugly",
226
+
227
+ },
228
+
229
+ {
230
+ "name": "(No style)",
231
+ "prompt": "{prompt}",
232
+ "negative_prompt": "",
233
+ },
234
+
235
+
236
+ ]
237
+ styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
238
+ STYLE_NAMES = list(styles.keys())
239
+ DEFAULT_STYLE_NAME = "(No style)"
240
+
241
+ def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
242
+ p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
243
+ if not negative:
244
+ negative = ""
245
+ return p.replace("{prompt}", positive), n + negative
246
+
247
+ @spaces.GPU(enable_queue=True)
248
+ def generate(
249
+ prompt: str,
250
+ negative_prompt: str = "",
251
+ style: str = DEFAULT_STYLE_NAME,
252
+ use_negative_prompt: bool = False,
253
+ num_inference_steps: int = 30,
254
+ num_images_per_prompt: int = 2,
255
+ seed: int = 0,
256
+ width: int = 1024,
257
+ height: int = 1024,
258
+ guidance_scale: float = 3,
259
+ randomize_seed: bool = False,
260
+ progress=gr.Progress(track_tqdm=True),
261
+ ):
262
+
263
+
264
+ seed = int(randomize_seed_fn(seed, randomize_seed))
265
+
266
+ if not use_negative_prompt:
267
+ negative_prompt = "" # type: ignore
268
+ prompt, negative_prompt = apply_style(style, prompt, negative_prompt)
269
+
270
+ images = pipe(
271
+ prompt=prompt,
272
+ negative_prompt=negative_prompt,
273
+ width=width,
274
+ height=height,
275
+ guidance_scale=guidance_scale,
276
+ num_inference_steps=num_inference_steps,
277
+ num_images_per_prompt=num_images_per_prompt,
278
+ cross_attention_kwargs={"scale": 0.65},
279
+ output_type="pil",
280
+ ).images
281
+ image_paths = [save_image(img) for img in images]
282
+ print(image_paths)
283
+ return image_paths, seed
284
 
285
  examples = [
286
+ "A castle sitting on top of a snow covered mountain, inspired by Raphael Lacoste, medieval village on the plains, wintry rumpelstiltskin, full res, ingame image, wallpaper, cliffside town, highdetailed, winter storm, thomas kincade, concept illustartion, tuomas korpi and wlop, concept art",
287
+ "Lost city of Atlantis, chaotic ocean, detailed, octane render, tall architectures, sharks + sealife, fish + corral, Unreal engine 5, 8k, --q 5 --s 7500 --ar 4:5",
288
+ "Photo illustration from a world in the clouds, in the style of tanya shatseva, the stars art group (xing xing), meghan howland, dark indigo and light cyan, mind-bending sculptures, realistic hyper-detail, fluid simplicity --ar 63:128 --stylize 750 --v 6",
289
+ "A confident woman detective with a sleek bobbed hairstyle cut and observant brown eyes, wearing a gray detective coat, is examining clues in a dimly lit crime scene, half-body:: portraited, face drawn by the masterful artist Wes Anderson, detailed, against a gritty background --ar 2:3 --niji 5 --style expressive --q 2"
290
  ]
291
 
292
+ css = '''
293
+ .gradio-container{max-width: 560px !important}
294
+ h1{text-align:center}
295
+ footer {
296
+ visibility: hidden
297
  }
298
+ '''
299
 
300
+ with gr.Blocks(css=css, theme="xiaobaiyuan/theme_brief") as demo:
301
+ gr.Markdown(DESCRIPTION)
302
+ gr.DuplicateButton(
303
+ value="Duplicate Space for private use",
304
+ elem_id="duplicate-button",
305
+ visible=False,
306
+ )
307
 
308
+ with gr.Group():
 
 
 
 
 
 
 
309
  with gr.Row():
 
310
  prompt = gr.Text(
311
  label="Prompt",
312
  show_label=False,
 
314
  placeholder="Enter your prompt",
315
  container=False,
316
  )
317
+ run_button = gr.Button("Run")
318
+ result = gr.Gallery(label="Result", columns=1, preview=True)
319
+ with gr.Accordion("Advanced options", open=False):
320
+ use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=False, visible=True)
321
+ negative_prompt = gr.Text(
 
 
 
322
  label="Negative prompt",
323
  max_lines=1,
324
  placeholder="Enter a negative prompt",
325
+ visible=True,
326
  )
327
+ with gr.Row():
328
+ num_inference_steps = gr.Slider(
329
+ label="Steps",
330
+ minimum=10,
331
+ maximum=60,
332
  step=1,
333
+ value=30,
334
  )
335
+ with gr.Row():
336
+ num_images_per_prompt = gr.Slider(
337
+ label="Images",
338
+ minimum=1,
339
+ maximum=5,
340
+ step=1,
341
+ value=2,
342
+ )
343
+ seed = gr.Slider(
344
+ label="Seed",
345
+ minimum=0,
346
+ maximum=MAX_SEED,
347
+ step=1,
348
+ value=0,
349
+ visible=True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  )
351
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
352
+ with gr.Row(visible=True):
353
+ width = gr.Slider(
354
+ label="Width",
355
+ minimum=512,
356
+ maximum=2048,
357
+ step=8,
358
+ value=1024,
359
+ )
360
+ height = gr.Slider(
361
+ label="Height",
362
+ minimum=512,
363
+ maximum=2048,
364
+ step=8,
365
+ value=1024,
366
+ )
367
+ with gr.Row():
368
+ guidance_scale = gr.Slider(
369
+ label="Guidance Scale",
370
+ minimum=0.1,
371
+ maximum=20.0,
372
+ step=0.1,
373
+ value=6,
374
+ )
375
+ with gr.Row(visible=True):
376
+ style_selection = gr.Radio(
377
+ show_label=True,
378
+ container=True,
379
+ interactive=True,
380
+ choices=STYLE_NAMES,
381
+ value=DEFAULT_STYLE_NAME,
382
+ label="Image Style",
383
+ )
384
+
385
+
386
+ gr.Examples(
387
+ examples=examples,
388
+ inputs=prompt,
389
+ outputs=[result, seed],
390
+ fn=generate,
391
+ cache_examples=False,
392
+ )
393
 
394
+ use_negative_prompt.change(
395
+ fn=lambda x: gr.update(visible=x),
396
+ inputs=use_negative_prompt,
397
+ outputs=negative_prompt,
398
+ api_name=False,
399
  )
400
+
401
+
402
+
403
+ gr.on(
404
+ triggers=[
405
+ prompt.submit,
406
+ negative_prompt.submit,
407
+ run_button.click,
408
+ ],
409
+ fn=generate,
410
+ inputs=[
411
+ prompt,
412
+ negative_prompt,
413
+ style_selection,
414
+ use_negative_prompt,
415
+ num_inference_steps,
416
+ num_images_per_prompt,
417
+ seed,
418
+ width,
419
+ height,
420
+ guidance_scale,
421
+ randomize_seed,
422
+ ],
423
+ outputs=[result, seed],
424
+ api_name="run",
425
+ )
426
+
427
+
428
 
429
+ if __name__ == "__main__":
430
+ demo.queue(max_size=20).launch(show_api=False, debug=False)