DGSpitzer commited on
Commit
57d08a9
1 Parent(s): f178d5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +242 -51
app.py CHANGED
@@ -1,64 +1,222 @@
1
- from diffusers import StableDiffusionPipeline
 
2
  import gradio as gr
3
  import torch
4
  import os
5
  from PIL import Image
 
 
 
6
 
7
  from share_btn import community_icon_html, loading_icon_html, share_js
8
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  if torch.cuda.is_available():
10
  torchfloat = torch.float16
11
  else:
12
  torchfloat = torch.float32
13
 
 
 
 
 
 
 
 
 
14
 
15
  models = [
16
- "DGSpitzer/Cyberpunk-Anime-Diffusion"
 
17
  ]
18
 
19
- prompt_prefixes = {
20
- models[0]: "dgs illustration style "
21
- }
 
22
 
23
- current_model = models[0]
 
 
24
 
25
- #auth_token = os.environ.get("test") or True
26
- #pipe = StableDiffusionPipeline.from_pretrained(current_model, use_auth_token=auth_token, torch_dtype=torchfloat, revision="fp16")
27
- pipe = StableDiffusionPipeline.from_pretrained(current_model, torch_dtype=torchfloat)
 
 
 
 
28
 
 
 
 
 
 
 
 
 
29
  if torch.cuda.is_available():
30
  pipe = pipe.to("cuda")
31
- else:
32
- pipe = pipe.to("cpu")
33
 
34
  device = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
35
 
36
- def on_model_change(model):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
- global current_model
 
 
39
  global pipe
40
- if model != current_model:
41
- current_model = model
42
- pipe = StableDiffusionPipeline.from_pretrained(current_model, torch_dtype=torchfloat)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  if torch.cuda.is_available():
44
- pipe = pipe.to("cuda")
45
-
46
- def inference(prompt, negPrompt, guidance, steps, width_input, height_input):
47
- print("Generated image with prompt: " + prompt)
48
- if negPrompt != "":
49
- print("Negative prompt: " + negPrompt)
50
- promptPrev = prompt
51
- prompt = prompt_prefixes[current_model] + prompt
52
- results = pipe(prompt, negative_prompt = negPrompt, num_inference_steps=int(steps), guidance_scale=guidance, width=width_input, height=height_input)
53
- image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
54
- return image, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
55
-
56
- def inference_example(prompt, negPrompt, guidance, steps, width_input, height_input):
 
57
 
58
- prompt = prompt_prefixes[current_model] + prompt
59
- results = pipe(prompt, negative_prompt = negPrompt, num_inference_steps=int(steps), guidance_scale=guidance, width=width_input, height=height_input)
60
- image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
61
- return image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  css = """
64
  #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
@@ -90,6 +248,7 @@ a {text-decoration-line: underline; font-weight: 600;}
90
  #share-btn-container .wrap {
91
  display: none !important;
92
  }
 
93
  """
94
 
95
  with gr.Blocks(css=css) as demo:
@@ -105,7 +264,7 @@ with gr.Blocks(css=css) as demo:
105
  "
106
  >
107
  <h1 style="font-weight: 900; margin-bottom: 7px;">
108
- DGS Diffusion Space
109
  </h1>
110
  </div>
111
  <p style="margin-bottom: 10px; font-size: 94%">
@@ -129,37 +288,68 @@ with gr.Blocks(css=css) as demo:
129
  with gr.Row():
130
 
131
  with gr.Column():
132
- model = gr.Dropdown(label="Model", choices=models, value=models[0])
133
- prompt = gr.Textbox(label="Prompt", placeholder="{} is added automatically".format(prompt_prefixes[current_model]), elem_id="input-prompt")
134
- negPrompt = gr.Textbox(label="Negative Prompt", placeholder="Enter what you don't want to generate", elem_id="input-negPrompt")
135
- guidance = gr.Slider(label="Guidance scale", value=7, maximum=8)
136
- steps = gr.Slider(label="Steps", value=20, maximum=30, minimum=2)
137
  width_input = gr.Slider(label="Width", value=576, maximum=768, minimum=384, step=64)
138
  height_input = gr.Slider(label="Height", value=576, maximum=768, minimum=384, step=64)
 
 
 
 
139
  run = gr.Button(value="Run")
140
  gr.Markdown(f"Running on: {device}")
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  with gr.Column():
142
  image_out = gr.Image(height=512, type="filepath", elem_id="output-img")
 
 
 
143
 
144
  with gr.Column(elem_id="col-container"):
145
  with gr.Group(elem_id="share-btn-container"):
146
  community_icon = gr.HTML(community_icon_html, visible=False)
147
  loading_icon = gr.HTML(loading_icon_html, visible=False)
148
  share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
149
-
150
- model.change(on_model_change, inputs=model, outputs=[])
151
- run.click(inference, inputs=[prompt, negPrompt, guidance, steps, width_input, height_input], outputs=[image_out, share_button, community_icon, loading_icon])
 
 
 
 
152
 
153
  share_button.click(None, [], [], _js=share_js)
154
 
155
  gr.Examples([
156
- ["perfect face portrait of beautiful smile girl, clean face, wears hoody, half body, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 512, 704],
157
- ["portrait of a beautiful fancy gorgeous anime girl, intricate details", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 448, 640],
158
- ["a beautiful perfect face girl, Anime fine details portrait of school girl in front of modern tokyo city landscape on the background deep bokeh, anime masterpiece by studio ghibli, 8k, sharp high quality anime, artstation", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
159
- ["city landscape with fancy car, racing on the road, gopro, intricate details, 4k, cyberpunk", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
160
- ["portrait of liu yifei girl, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
161
- ["portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 512, 640],
162
- ], [prompt, negPrompt, guidance, steps, width_input, height_input], image_out, inference_example, cache_examples=torch.cuda.is_available())
 
 
 
 
 
 
 
 
163
  gr.Markdown('''
164
  Models and Space by [@DGSpitzer](https://www.youtube.com/channel/UCzzsYBF4qwtMwJaPJZ5SuPg)❤️ [@大谷的游戏创作小屋](https://space.bilibili.com/176003)
165
  [![Twitter Follow](https://img.shields.io/twitter/follow/DGSpitzer?label=%40DGSpitzer&style=social)](https://twitter.com/DGSpitzer)
@@ -169,5 +359,6 @@ with gr.Blocks(css=css) as demo:
169
 
170
  ''')
171
 
172
- demo.queue()
173
- demo.launch()
 
 
1
+ from diffusers import AutoencoderKL, UNet2DConditionModel, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
2
+ from diffusers import EulerAncestralDiscreteScheduler
3
  import gradio as gr
4
  import torch
5
  import os
6
  from PIL import Image
7
+ import datetime
8
+ import time
9
+ import psutil
10
 
11
  from share_btn import community_icon_html, loading_icon_html, share_js
12
 
13
+ def is_google_colab():
14
+ try:
15
+ import google.colab
16
+ return True
17
+ except:
18
+ return False
19
+
20
+ is_colab = is_google_colab()
21
+
22
+ start_time = time.time()
23
+
24
+
25
  if torch.cuda.is_available():
26
  torchfloat = torch.float16
27
  else:
28
  torchfloat = torch.float32
29
 
30
+ class Model:
31
+ def __init__(self, name, path="", prefix=""):
32
+ self.name = name
33
+ self.path = path
34
+ self.prefix = prefix
35
+ self.pipe_t2i = None
36
+ self.pipe_i2i = None
37
+
38
 
39
  models = [
40
+ Model("Cyberpunk Anime Diffusion", "DGSpitzer/Cyberpunk-Anime-Diffusion", "dgs illustration style "),
41
+ Model("Guan Yu Diffusion", "DGSpitzer/Guan-Yu-Diffusion", "")
42
  ]
43
 
44
+ custom_model = None
45
+ if is_colab:
46
+ models.insert(0, Model("Custom model"))
47
+ custom_model = models[0]
48
 
49
+ last_mode = "txt2img"
50
+ current_model = models[1] if is_colab else models[0]
51
+ current_model_path = current_model.path
52
 
53
+ if is_colab:
54
+ pipe = StableDiffusionPipeline.from_pretrained(
55
+ current_model.path,
56
+ torch_dtype=torch.float16,
57
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler"),
58
+ safety_checker=lambda images, clip_input: (images, False)
59
+ )
60
 
61
+ else:
62
+ eulera = EulerAncestralDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
63
+ pipe = StableDiffusionPipeline.from_pretrained(
64
+ current_model.path,
65
+ torch_dtype=torch.float16,
66
+ scheduler=eulera
67
+ )
68
+
69
  if torch.cuda.is_available():
70
  pipe = pipe.to("cuda")
71
+ #pipe.enable_xformers_memory_efficient_attention()
 
72
 
73
  device = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
74
 
75
+ def error_str(error, title="Error"):
76
+ return f"""#### {title}
77
+ {error}""" if error else ""
78
+
79
+ def custom_model_changed(path):
80
+ models[0].path = path
81
+ global current_model
82
+ current_model = models[0]
83
+
84
+ def on_model_change(model_name):
85
+
86
+ prefix = "Enter prompt. \"" + next((m.prefix for m in models if m.name == model_name), None) + "\" is prefixed automatically" if model_name != models[0].name else "Don't forget to use the custom model prefix in the prompt!"
87
+
88
+ return gr.update(visible = model_name == models[0].name), gr.update(placeholder=prefix)
89
+
90
+ def inference(model_name, prompt, neg_prompt, guidance, steps, width=512, height=512, seed=0, img=None, strength=0.5, n_images=1):
91
+ print("Generated image with prompt: " + prompt)
92
+ if neg_prompt != "":
93
+ print("Negative prompt: " + neg_prompt)
94
+
95
+ print(psutil.virtual_memory()) # print memory usage
96
+
97
+ global current_model
98
+ for model in models:
99
+ if model.name == model_name:
100
+ current_model = model
101
+ model_path = current_model.path
102
+
103
+ generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
104
+
105
+ try:
106
+ if img is not None:
107
+ return img_to_img(model_path, prompt, neg_prompt, img, strength, guidance, steps, width, height, n_images, generator), None, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
108
+ else:
109
+ return txt_to_img(model_path, prompt, neg_prompt, guidance, steps, width, height, n_images, generator), None, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
110
+ except Exception as e:
111
+ return None, error_str(e), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
112
+
113
+ def inference_example(model_name, prompt, neg_prompt, guidance, steps, width=512, height=512):
114
+ _image, _error, _bool1, _bool2, _bool3 = inference(model_name, prompt, neg_prompt, guidance, steps, width, height)
115
+ return _image
116
+
117
+
118
+ def txt_to_img(model_path, prompt, neg_prompt, guidance, steps, width, height, n_images, generator):
119
 
120
+ print(f"{datetime.datetime.now()} txt_to_img, model: {current_model.name}")
121
+
122
+ global last_mode
123
  global pipe
124
+ global current_model_path
125
+ if model_path != current_model_path or last_mode != "txt2img":
126
+ current_model_path = model_path
127
+
128
+ if is_colab or current_model == custom_model:
129
+ pipe = StableDiffusionPipeline.from_pretrained(
130
+ current_model_path,
131
+ torch_dtype=torch.float16,
132
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler"),
133
+ safety_checker=lambda images, clip_input: (images, False)
134
+ )
135
+ else:
136
+ pipe = StableDiffusionPipeline.from_pretrained(
137
+ current_model_path,
138
+ torch_dtype=torch.float16,
139
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler")
140
+ )
141
+ # pipe = pipe.to("cpu")
142
+ # pipe = current_model.pipe_t2i
143
+
144
  if torch.cuda.is_available():
145
+ pipe = pipe.to("cuda")
146
+ pipe.enable_xformers_memory_efficient_attention()
147
+ last_mode = "txt2img"
148
+
149
+ prompt = current_model.prefix + prompt
150
+ result = pipe(
151
+ prompt,
152
+ negative_prompt = neg_prompt,
153
+ num_images_per_prompt=n_images,
154
+ num_inference_steps = int(steps),
155
+ guidance_scale = guidance,
156
+ width = width,
157
+ height = height,
158
+ generator = generator)
159
 
160
+ return replace_nsfw_images(result)
161
+
162
+ def img_to_img(model_path, prompt, neg_prompt, img, strength, guidance, steps, width, height, n_images, generator):
163
+
164
+ print(f"{datetime.datetime.now()} img_to_img, model: {model_path}")
165
+
166
+ global last_mode
167
+ global pipe
168
+ global current_model_path
169
+ if model_path != current_model_path or last_mode != "img2img":
170
+ current_model_path = model_path
171
+
172
+ if is_colab or current_model == custom_model:
173
+ pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
174
+ current_model_path,
175
+ torch_dtype=torch.float16,
176
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler"),
177
+ safety_checker=lambda images, clip_input: (images, False)
178
+ )
179
+ else:
180
+ pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
181
+ current_model_path,
182
+ torch_dtype=torch.float16,
183
+ scheduler=DPMSolverMultistepScheduler.from_pretrained(current_model.path, subfolder="scheduler")
184
+ )
185
+ # pipe = pipe.to("cpu")
186
+ # pipe = current_model.pipe_i2i
187
+
188
+ if torch.cuda.is_available():
189
+ pipe = pipe.to("cuda")
190
+ pipe.enable_xformers_memory_efficient_attention()
191
+ last_mode = "img2img"
192
+
193
+ prompt = current_model.prefix + prompt
194
+ ratio = min(height / img.height, width / img.width)
195
+ img = img.resize((int(img.width * ratio), int(img.height * ratio)), Image.LANCZOS)
196
+ result = pipe(
197
+ prompt,
198
+ negative_prompt = neg_prompt,
199
+ num_images_per_prompt=n_images,
200
+ image = img,
201
+ num_inference_steps = int(steps),
202
+ strength = strength,
203
+ guidance_scale = guidance,
204
+ # width = width,
205
+ # height = height,
206
+ generator = generator)
207
+
208
+ return replace_nsfw_images(result)
209
+
210
+ def replace_nsfw_images(results):
211
+ #Only return 1 image for community sharing
212
+ if is_colab:
213
+ return results.images[0]
214
+
215
+ for i in range(len(results.images)):
216
+ if results.nsfw_content_detected[i]:
217
+ results.images[i] = Image.open("nsfw_placeholder.jpg")
218
+ return results.images[0]
219
+
220
 
221
  css = """
222
  #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
 
248
  #share-btn-container .wrap {
249
  display: none !important;
250
  }
251
+ #gallery{min-height:20rem}
252
  """
253
 
254
  with gr.Blocks(css=css) as demo:
 
264
  "
265
  >
266
  <h1 style="font-weight: 900; margin-bottom: 7px;">
267
+ DGSpitzer Diffusion Space
268
  </h1>
269
  </div>
270
  <p style="margin-bottom: 10px; font-size: 94%">
 
288
  with gr.Row():
289
 
290
  with gr.Column():
291
+ model_name = gr.Dropdown(label="Model", choices=[m.name for m in models], value=current_model.name)
292
+ #prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2, placeholder="Enter your prompt~", elem_id="input-prompt").style(container=False)
293
+ prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2, placeholder="Enter your prompt~", elem_id="input-prompt")
294
+ neg_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter what you don't want to generate", elem_id="input-neg-prompt")
 
295
  width_input = gr.Slider(label="Width", value=576, maximum=768, minimum=384, step=64)
296
  height_input = gr.Slider(label="Height", value=576, maximum=768, minimum=384, step=64)
297
+ #n_images = gr.Slider(label="Images", value=1, minimum=1, maximum=4, step=1)
298
+ guidance = gr.Slider(label="Guidance scale", value=7, maximum=10)
299
+ steps = gr.Slider(label="Steps", value=20, maximum=50, minimum=2)
300
+ seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1)
301
  run = gr.Button(value="Run")
302
  gr.Markdown(f"Running on: {device}")
303
+
304
+ # with gr.Column(scale=45):
305
+ # with gr.Tab("Text to Image"):
306
+ # with gr.Group():
307
+ # gr.Markdown(f"Current in text to Image Mode, ")
308
+ # #seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1)
309
+
310
+ # with gr.Tab("Image to Image"):
311
+ # with gr.Group():
312
+ # gr.Markdown(f"Image to Image Mode")
313
+ # image = gr.Image(label="Image", height=256, tool="editor", type="pil")
314
+ # strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
315
+
316
  with gr.Column():
317
  image_out = gr.Image(height=512, type="filepath", elem_id="output-img")
318
+ error_output = gr.Markdown()
319
+ #gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
320
+
321
 
322
  with gr.Column(elem_id="col-container"):
323
  with gr.Group(elem_id="share-btn-container"):
324
  community_icon = gr.HTML(community_icon_html, visible=False)
325
  loading_icon = gr.HTML(loading_icon_html, visible=False)
326
  share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
327
+
328
+ if is_colab:
329
+ model_name.change(on_model_change, inputs=model_name, outputs=[custom_model_group, prompt], queue=False)
330
+ custom_model_path.change(custom_model_changed, inputs=custom_model_path, outputs=None)
331
+
332
+ #outputs = [gallery, error_output]
333
+ run.click(inference, inputs=[model_name, prompt, neg_prompt, guidance, steps, width_input, height_input, seed], outputs=[image_out, error_output, share_button, community_icon, loading_icon])
334
 
335
  share_button.click(None, [], [], _js=share_js)
336
 
337
  gr.Examples([
338
+ [models[0].name, "perfect face portrait of beautiful smile girl, clean face, wears hoody, half body, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 512, 704],
339
+ [models[0].name, "portrait of a beautiful fancy gorgeous anime girl, intricate details", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 448, 640],
340
+ [models[0].name, "a beautiful perfect face girl, Anime fine details portrait of school girl in front of modern tokyo city landscape on the background deep bokeh, anime masterpiece by studio ghibli, 8k, sharp high quality anime, artstation", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
341
+ [models[0].name, "city landscape with fancy car, racing on the road, gopro, intricate details, 4k, cyberpunk", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
342
+ [models[0].name, "portrait of liu yifei girl, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
343
+ [models[0].name, "portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 512, 640],
344
+ [models[1].name, "Portrait of guanyu walking in ancient battlefield, close up shot", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 576, 576],
345
+ [models[1].name, "Portrait of a man holding very cute panda plushie, Guanyu", "", 7, 30, 576, 576],
346
+ [models[1].name, "taking selfie on ancient battlefield of China, guanyu, gopro, sharp focus, old scratched photo, three kingdoms warriors everywhere, masterpiece", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 576, 576],
347
+ [models[1].name, "portrait of a superman stands in a cyberpunk city, guanyu", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 512, 704],
348
+ [models[1].name, "portrait of batman guanyu with armor, close up shot, city night background", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 576, 576],
349
+ [models[1].name, "a gorgeous wuxia girl standing in the palace", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 576, 576],
350
+ [models[1].name, "a handsome wuxia man", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 30, 576, 576],
351
+ [models[1].name, "a wuxia girl diving underwater, surrounded by a shark", "blurry, out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 576, 576],
352
+ ], [model_name, prompt, neg_prompt, guidance, steps, width_input, height_input], outputs=image_out, fn=inference_example, cache_examples=torch.cuda.is_available())
353
  gr.Markdown('''
354
  Models and Space by [@DGSpitzer](https://www.youtube.com/channel/UCzzsYBF4qwtMwJaPJZ5SuPg)❤️ [@大谷的游戏创作小屋](https://space.bilibili.com/176003)
355
  [![Twitter Follow](https://img.shields.io/twitter/follow/DGSpitzer?label=%40DGSpitzer&style=social)](https://twitter.com/DGSpitzer)
 
359
 
360
  ''')
361
 
362
+ if not is_colab:
363
+ demo.queue(concurrency_count=1)
364
+ demo.launch(debug=is_colab, share=is_colab)