File size: 22,614 Bytes
a359b6d
fa77a94
5da0d3d
a359b6d
cd7f3ee
a359b6d
 
6cf80c2
a359b6d
6cf80c2
a359b6d
 
 
1b101d7
 
 
a359b6d
5e22611
a359b6d
5e22611
 
a359b6d
 
 
 
 
5e22611
a359b6d
4a237f8
a359b6d
6f7ae8f
 
 
 
 
 
 
 
 
 
 
a359b6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5e22611
a359b6d
 
 
 
aa33c7d
a359b6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97cc1f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b65cd60
 
 
97cc1f0
1b101d7
 
 
 
cffda6e
1b101d7
 
6f7ae8f
 
1b101d7
 
cffda6e
2db66d7
6f7ae8f
1b101d7
6f7ae8f
 
 
1b101d7
 
6f7ae8f
 
 
1707f2c
6f7ae8f
 
97cc1f0
 
 
 
 
 
 
 
 
 
 
 
 
e7d490b
 
9e2e3c5
 
 
 
e7d490b
9e2e3c5
 
 
 
 
e7d490b
 
97cc1f0
877dee8
 
97cc1f0
c3062cb
 
 
 
 
 
877dee8
 
97cc1f0
 
 
 
 
 
 
 
 
 
 
 
b65cd60
97cc1f0
b65cd60
 
 
75d45a1
97cc1f0
 
 
 
9e2e3c5
 
 
 
 
 
 
 
5cb92bb
e7d490b
97cc1f0
 
5e22611
 
877dee8
a359b6d
877dee8
 
 
 
 
 
 
 
 
 
453901b
 
 
 
877dee8
 
 
 
453901b
877dee8
 
a359b6d
877dee8
 
a359b6d
877dee8
 
a359b6d
877dee8
 
 
 
c57aea2
877dee8
 
c57aea2
 
 
 
 
 
 
ebc5fd4
c57aea2
 
ebc5fd4
 
 
c57aea2
877dee8
 
1b101d7
 
 
877dee8
 
1b101d7
cffda6e
1b101d7
6f7ae8f
1b101d7
 
 
cffda6e
2db66d7
6f7ae8f
1b101d7
6f7ae8f
 
 
1b101d7
 
877dee8
6f7ae8f
 
1707f2c
6f7ae8f
 
 
 
 
4eca7fa
877dee8
6b22177
 
9761641
 
 
877dee8
 
 
 
d370d46
c3062cb
 
d370d46
c3062cb
 
877dee8
 
 
4eca7fa
ebc5fd4
 
4eca7fa
877dee8
 
 
 
 
c57aea2
877dee8
 
 
 
6b22177
877dee8
a359b6d
877dee8
 
a359b6d
7e14edd
a359b6d
 
5e22611
a359b6d
 
6b22177
77195a0
6b22177
a359b6d
 
 
 
 
 
 
 
 
 
 
 
 
5e22611
 
 
97cc1f0
 
a359b6d
6cf80c2
a359b6d
97cc1f0
877dee8
 
 
 
97cc1f0
a359b6d
 
 
 
877dee8
a359b6d
 
 
 
 
6b22177
 
 
 
 
 
 
77195a0
6b22177
 
 
3708c86
 
 
6b22177
 
 
 
3b5016f
 
 
 
6b22177
 
 
 
 
3b5016f
 
 
 
 
 
 
 
 
 
 
6b22177
901b267
 
 
 
 
 
 
 
 
 
 
24976a8
bbadd6b
 
 
 
 
 
c57aea2
bbadd6b
901b267
bbadd6b
c57aea2
901b267
 
c57aea2
901b267
c57aea2
 
 
 
901b267
0cbffa0
 
 
 
 
 
 
 
 
 
 
24976a8
0cbffa0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24976a8
0cbffa0
 
 
 
 
 
 
 
 
 
 
 
 
1c66d59
24976a8
 
0cbffa0
10f7ab2
0cbffa0
 
 
 
10f7ab2
0cbffa0
 
 
 
 
 
 
 
 
 
 
 
 
24976a8
0cbffa0
10f7ab2
0cbffa0
 
 
6b22177
 
 
97cc1f0
 
24976a8
 
871d7f6
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
#@title Prepare the Concepts Library to be used


import requests
import os
import gradio as gr
import wget
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline
from huggingface_hub import HfApi
from transformers import CLIPTextModel, CLIPTokenizer
import html
import datetime

image_count = 0

community_icon_html = ""

loading_icon_html = ""
share_js = ""

api = HfApi()
models_list = api.list_models(author="sd-concepts-library", sort="likes", direction=-1)
models = []

my_token = os.environ['api_key']

pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", revision="fp16", torch_dtype=torch.float16, use_auth_token=my_token).to("cuda")

def check_prompt(prompt):
    SPAM_WORDS = [
        "seductive",
        "breast"
    ]
    for spam_word in SPAM_WORDS:
        if spam_word in prompt:
            return False
    return True


def load_learned_embed_in_clip(learned_embeds_path, text_encoder, tokenizer, token=None):
  loaded_learned_embeds = torch.load(learned_embeds_path, map_location="cpu")
  
  _old_token = token
  # separate token and the embeds
  trained_token = list(loaded_learned_embeds.keys())[0]
  embeds = loaded_learned_embeds[trained_token]

  # cast to dtype of text_encoder
  dtype = text_encoder.get_input_embeddings().weight.dtype
  
  # add the token in tokenizer
  token = token if token is not None else trained_token
  num_added_tokens = tokenizer.add_tokens(token)
  i = 1
  while(num_added_tokens == 0):
    token = f"{token[:-1]}-{i}>"
    num_added_tokens = tokenizer.add_tokens(token)
    i+=1
  
  # resize the token embeddings
  text_encoder.resize_token_embeddings(len(tokenizer))
  
  # get the id for the token and assign the embeds
  token_id = tokenizer.convert_tokens_to_ids(token)
  text_encoder.get_input_embeddings().weight.data[token_id] = embeds
  return token


ahx_model_list = [model for model in models_list if "ahx" in model.modelId]
ahx_dropdown_list = [model for model in models_list if "ahx-model" in model.modelId]


for model in ahx_model_list:
  model_content = {}
  model_id = model.modelId
  model_content["id"] = model_id
  embeds_url = f"https://huggingface.co/{model_id}/resolve/main/learned_embeds.bin"
  os.makedirs(model_id,exist_ok = True)
  if not os.path.exists(f"{model_id}/learned_embeds.bin"):
    try:
      wget.download(embeds_url, out=model_id)
    except:
      continue

  token_identifier = f"https://huggingface.co/{model_id}/raw/main/token_identifier.txt"
  response = requests.get(token_identifier)
  token_name = response.text
  
  concept_type = f"https://huggingface.co/{model_id}/raw/main/type_of_concept.txt"
  response = requests.get(concept_type)
  concept_name = response.text
  model_content["concept_type"] = concept_name
  images = []
  for i in range(4):
    url = f"https://huggingface.co/{model_id}/resolve/main/concept_images/{i}.jpeg"
    image_download = requests.get(url)
    url_code = image_download.status_code
    if(url_code == 200):
      file = open(f"{model_id}/{i}.jpeg", "wb") ## Creates the file for image
      file.write(image_download.content) ## Saves file content
      file.close()
      images.append(f"{model_id}/{i}.jpeg")
  model_content["images"] = images
  #if token cannot be loaded, skip it
  try:
    learned_token = load_learned_embed_in_clip(f"{model_id}/learned_embeds.bin", pipe.text_encoder, pipe.tokenizer, token_name)
  except: 
    continue
  model_content["token"] = learned_token
  models.append(model_content)
  models.append(model_content)


# -----------------------------------------------------------------------------------------------


#@title Dropdown Prompt Tab

model_tags = [model.modelId.split("/")[1] for model in ahx_model_list]
model_tags.sort()


import random 


#@title Gradio Concept Loader
DROPDOWNS = {}

for model in model_tags:
  if model != "ahx-model-1" and model != "ahx-model-2":
    DROPDOWNS[model] = f" in the style of <{model}>"

# def image_prompt(prompt, dropdown, guidance, steps, seed, height, width):
def image_prompt(prompt, guidance, steps, seed, height, width):
  # prompt = prompt + DROPDOWNS[dropdown]
  square_pixels = height * width
  if square_pixels > 640000:
      height = 640000 // width
  generator = torch.Generator(device="cuda").manual_seed(int(seed))

  height=int((height // 8) * 8)
  width=int((width // 8) * 8)

  # image_count += 1
  curr_time = datetime.datetime.now()

  is_clean = check_prompt(prompt)

  print("----- advanced tab prompt ------------------------------")
  print(f"prompt: {prompt}, size: {width}px x {height}px, guidance: {guidance}, steps: {steps}, seed: {int(seed)}")
  # print(f"image_count: {image_count}, datetime: `{e}`")
  print(f"datetime: `{curr_time}`")
  print(f"is_prompt_clean: {is_clean}")
  print("-------------------------------------------------------")

  if is_clean:
    return (
      pipe(prompt=prompt, guidance_scale=guidance, num_inference_steps=steps, generator=generator, height=height, width=width).images[0], 
      f"prompt: '{prompt}', seed = {int(seed)},\nheight: {height}px, width: {width}px,\nguidance: {guidance}, steps: {steps}"
    )
  else:
    return (
      pipe(prompt="", guidance_scale=0, num_inference_steps=1, generator=generator, height=32, width=32).images[0], 
      f"Prompt violates Hugging Face's Terms of Service"
    )

def default_guidance():
  return 7.5

def default_steps():
  return 30

def default_pixel():
  return 768

def random_seed():
  return random.randint(0, 99999999999999) # <-- this is a random gradio limit, the seed range seems to actually be 0-18446744073709551615



def get_models_text():
  # make markdown text for available models...
  markdown_model_tags = [f"<{model}>" for model in model_tags if model != "ahx-model-1" and model != "ahx-model-2"]
  markdown_model_text = "\n".join(markdown_model_tags)

  # make markdown text for available betas...
  markdown_betas_tags = [f"<{model}>" for model in model_tags if "beta" in model]
  markdown_betas_text = "\n".join(markdown_model_tags)

  return f"## Available Artist Models / Concepts:\n" + markdown_model_text + "\n\n## Available Beta Models / Concepts:\n" + markdown_betas_text


with gr.Blocks(css=".gradio-container {max-width: 650px}") as dropdown_tab:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Advanced Concept Loader

      This tool allows you to run your own text prompts into fine-tuned artist concepts with individual parameter controls. Text prompts need to manually include artist concept / model tokens, see the examples below. The seed controls the static starting.
      <br>
      <br>
      The images you generate here are not recorded unless you choose to share them. Please share any cool images / prompts on the community tab here or our discord server! 
      <br>
      <br>
      <a href="http://www.astronaut.horse">http://www.astronaut.horse</a>
  ''')

  with gr.Row():
    prompt = gr.Textbox(label="image prompt...", elem_id="input-text")
  with gr.Row():
    seed = gr.Slider(0, 99999999999999, label="seed", dtype=int, value=random_seed, interactive=True, step=1)
  with gr.Row():
    with gr.Column():
      guidance = gr.Slider(0, 10, label="guidance", dtype=float, value=default_guidance, step=0.1, interactive=True)
    with gr.Column():
      steps = gr.Slider(1, 100, label="inference steps", dtype=int, value=default_steps, step=1, interactive=True)
  with gr.Row():
    with gr.Column():
      width = gr.Slider(144, 4200, label="width", dtype=int, value=default_pixel, step=8, interactive=True)
    with gr.Column():
      height = gr.Slider(144, 4200, label="height", dtype=int, value=default_pixel, step=8, interactive=True)
  gr.Markdown("<u>heads-up</u>: Height multiplied by width should not exceed about 645,000 or an error may occur. If an error occours refresh your browser tab or errors will continue. If you exceed this range the app will attempt to avoid an error by lowering your input height. We are actively seeking out ways to handle higher resolutions!")
  
  go_button = gr.Button("generate image", elem_id="go-button")
  output = gr.Image(elem_id="output-image")
  output_text = gr.Text(elem_id="output-text")
  # go_button.click(fn=image_prompt, inputs=[prompt, dropdown, guidance, steps, seed, height, width], outputs=[output, output_text])
  go_button.click(fn=image_prompt, inputs=[prompt, guidance, steps, seed, height, width], outputs=[output, output_text])
  # gr.Markdown('''
  #   ## Prompt Examples Using Artist Tokens:
  #   * "an alien in the style of \<ahx-model-12>"
  #   * "a painting in the style of \<ahx-model-11>"
  #   * "a landscape in the style of \<ahx-model-10> and \<ahx-model-14> "

  #   ## Valid Artist Tokens:
  # ''')
  gr.Markdown("For a complete list of usable models and beta concepts check out the dropdown selectors in the welcome and beta concepts tabs or the project's main website or our discord.\n\nhttp://www.astronaut.horse/concepts")
    

# -----------------------------------------------------------------------------------------------


#@title Dropdown Prompt Tab

model_tags = [model.modelId.split("/")[1] for model in ahx_model_list]
model_tags.sort()


import random 


#@title Gradio Concept Loader
DROPDOWNS = {}

# set a default for empty entries...
DROPDOWNS[''] = ''

# populate the dropdowns with full appendable style strings...
for model in model_tags:
  if model != "ahx-model-1" and model != "ahx-model-2":
    DROPDOWNS[model] = f" in the style of <{model}>"

# set pipe param defaults...
def default_guidance():
  return 7.5

def default_steps():
  return 30

def default_pixel():
  return 768

def random_seed():
  return random.randint(0, 99999999999999) # <-- this is a random gradio limit, the seed range seems to actually be 0-18446744073709551615


def simple_image_prompt(prompt, dropdown, size_dropdown):
  seed = random_seed()
  guidance = 7.5

  if size_dropdown == 'landscape':
      height = 624
      width = 1024
  elif size_dropdown == 'portrait':
      height = 1024
      width = 624
  elif size_dropdown == 'square':
      height = 768
      width = 768
  else:
      height = 1024
      width = 624
      
  steps = 30

  height=int((height // 8) * 8)
  width=int((width // 8) * 8)

  prompt = prompt + DROPDOWNS[dropdown]
  generator = torch.Generator(device="cuda").manual_seed(int(seed))

  # image_count += 1
  curr_time = datetime.datetime.now()
  is_clean = check_prompt(prompt)
    
  print("----- welcome / beta tab prompt ------------------------------")
  print(f"prompt: {prompt}, size: {width}px x {height}px, guidance: {guidance}, steps: {steps}, seed: {int(seed)}")
  # print(f"image_count: {image_count}, datetime: `{e}`")
  print(f"datetime: `{curr_time}`")
  print(f"is_prompt_clean: {is_clean}")
  print("-------------------------------------------------------")

  if is_clean:
    return (
      pipe(prompt=prompt, guidance_scale=guidance, num_inference_steps=steps, generator=generator, height=height, width=width).images[0], 
      f"prompt: '{prompt}', seed = {int(seed)},\nheight: {height}px, width: {width}px,\nguidance: {guidance}, steps: {steps}"
      )
  else:
    return (
      pipe(prompt="", guidance_scale=0, num_inference_steps=1, generator=generator, height=32, width=32).images[0], 
      f"Prompt violates Hugging Face's Terms of Service"
    )

    
  
    

    
# ~~~ WELCOME TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rand_model_int = 2

with gr.Blocks(css=".gradio-container {max-width: 650px}") as new_welcome:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Astronaut Horse Concept Loader

      This tool allows you to run your own text prompts into fine-tuned artist concepts from an ongoing series of Stable Diffusion collaborations with visual artists linked below. Select an artist's fine-tuned concept / model from the dropdown and enter any desired text prompt. You can check out example output images and project details on the project's webpage. Additionally you can play around with more controls in the Advanced Prompting tab.
      <br>
      <br>
      The images you generate here are not recorded unless you choose to share them. Please share any cool images / prompts on the community tab here or our discord server!
      <br>
      <br>
      <a href="http://www.astronaut.horse">http://www.astronaut.horse</a>
  ''')

  with gr.Row():
    dropdown = gr.Dropdown([dropdown for dropdown in list(DROPDOWNS) if 'ahx-model' in dropdown], label="choose style...")
    size_dropdown = gr.Dropdown(['square', 'portrait', 'landscape'], label="choose size...")
    # dropdown = gr.Dropdown(['1 image', '2 images', '3 images', '4 images'], label="output image count...")
  prompt = gr.Textbox(label="image prompt...", elem_id="input-text")

  go_button = gr.Button("generate image", elem_id="go-button")
  output = gr.Image(elem_id="output-image")
  output_text = gr.Text(elem_id="output-text")
  go_button.click(fn=simple_image_prompt, inputs=[prompt, dropdown, size_dropdown], outputs=[output, output_text])

# -----------------------------------------------------------------------------------------------



def infer(text, dropdown):
  images_list = pipe(
              [f"{text} in the style of <{dropdown}>"],
              num_inference_steps=30,
              guidance_scale=7.5
  )
  return images_list.images, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)

css = ""
examples = []


# ~~~ UNUSED DEMO TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

with gr.Blocks(css=css) as demo:
  state = gr.Variable({
        'selected': -1
  })
  state = {}
  def update_state(i):
        global checkbox_states
        if(checkbox_states[i]):
          checkbox_states[i] = False
          state[i] = False
        else:
          state[i] = True
          checkbox_states[i] = True
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Astronaut Horse Concept Loader

      This tool allows you to run your own text prompts into fine-tuned artist concepts from an ongoing series of Stable Diffusion collaborations with visual artists linked below. Select an artist's fine-tuned concept / model from the dropdown and enter any desired text prompt. You can check out example output images and project details on the project's webpage. Additionally if you can play around with more controls in the Advanced Prompting tab. Enjoy!
      <a href="http://www.astronaut.horse">http://www.astronaut.horse</a>
  ''')
  with gr.Row():
        with gr.Column():
          dropdown = gr.Dropdown(list(DROPDOWNS), label="choose style...")
          text = gr.Textbox(
              label="Enter your prompt", placeholder="Enter your prompt", show_label=False, max_lines=1, elem_id="prompt_input"
          )
          btn = gr.Button("generate image",elem_id="run_btn")
          infer_outputs = gr.Gallery(show_label=False, elem_id="generated-gallery").style(grid=[1])
          with gr.Group(elem_id="share-btn-container"):
            community_icon = gr.HTML(community_icon_html, visible=False)
            loading_icon = gr.HTML(loading_icon_html, visible=False)
  checkbox_states = {}
  inputs = [text, dropdown]
  btn.click(
        infer,
        inputs=inputs,
        outputs=[infer_outputs, community_icon, loading_icon]
    )


# -----------------------------------------------------------------------------------------------

# ~~~ BETA TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


with gr.Blocks() as beta:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Beta Concept Loader

      This tool allows you to test out newly trained beta concepts trained by artists. These are experimental and may be removed if they are problematic or uninteresting. If they end up  successful though they'll be renamed and moved into the primary prompting drop-down.
      
      To add to this artists can now freely train new models / concepts using the link below. This uses free access to Google's GPUs but will require a password / key that you can get from our discord. After a new concept / model is trained it will be automatically added to this tab after ~24 hours!
      
      <a href="https://colab.research.google.com/drive/1FhOpcEjHT7EN53Zv9MFLQTytZp11wjqg#scrollTo=hzUluHT-I42O">https://colab.research.google.com/astronaut-horse-training-tool</a>
  ''')

  with gr.Row():
    dropdown = gr.Dropdown([dropdown for dropdown in list(DROPDOWNS) if 'ahx-beta' in dropdown], label="choose style...")
    size_dropdown = gr.Dropdown(['square', 'portrait', 'landscape'], label="choose size...")
    # dropdown = gr.Dropdown(['1 image', '2 images', '3 images', '4 images'], label="output image count...")
  prompt = gr.Textbox(label="image prompt...", elem_id="input-text")

  go_button = gr.Button("generate image", elem_id="go-button")
  output = gr.Image(elem_id="output-image")
  output_text = gr.Text(elem_id="output-text")
  go_button.click(fn=simple_image_prompt, inputs=[prompt, dropdown, size_dropdown], outputs=[output, output_text])

  

  # with gr.Row():
  # prompt = gr.Textbox(label="image prompt...", elem_id="input-text")

  # go_button = gr.Button("generate image", elem_id="go-button")
  # output = gr.Image(elem_id="output-image")
  # output_text = gr.Text(elem_id="output-text")
  # go_button.click(fn=simple_image_prompt, inputs=[prompt, dropdown], outputs=[output, output_text])


    
# -----------------------------------------------------------------------------------------------

# ~~~ NOISE STEPS TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


with gr.Blocks() as noise_steps:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Noise Steps Loader

      This tool doesn't exist yet! 
      
      When it's built out though the plan is for it to let you expose the de-noising process that helps define Stable Diffusion image generation. 
      
      The plan is to let you enter custom a custom prompt / seed etc and see how Stable Diffusion is turning it's starting static image into an image that matches your prompt step-by-step. 
      
      Hopefully it'll be working soon. Check out the example below for now!

      ![denoising image](https://cdn.discordapp.com/attachments/1082744000806658098/1088575231158923304/Untitled.png)
  ''')
  # ![denoising image](https://cdn.discordapp.com/attachments/1082744000806658098/1088577845061759026/Untitled.png)
  # dropdown = gr.Dropdown([dropdown for dropdown in list(DROPDOWNS) if 'ahx-beta' in dropdown], label="choose style...")

  # with gr.Row():
  # prompt = gr.Textbox(label="image prompt...", elem_id="input-text")

  # go_button = gr.Button("generate image", elem_id="go-button")
  # output = gr.Image(elem_id="output-image")
  # output_text = gr.Text(elem_id="output-text")
  # go_button.click(fn=simple_image_prompt, inputs=[prompt, dropdown], outputs=[output, output_text])


    
# -----------------------------------------------------------------------------------------------

# ~~~ Depth Map TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


with gr.Blocks() as depth_map:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Depth Map Processor

      This tool doesn't exist yet! When it's built it will let you input any image from your phone or computer and process it into a depth map image using a Stable Diffusion control net process. Hopefully it'll be working soon. Check out the example below for now!

      ![Escher hands](https://cdn.discordapp.com/attachments/1065349726007992411/1089030239201534063/IMG_1874.jpg)
      ![Escher hands depth map](https://cdn.discordapp.com/attachments/1085605267481309197/1089031503612227705/tmp2bsa61a8.png)
  ''')


    
# -----------------------------------------------------------------------------------------------

# ~~~ Control Net TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


with gr.Blocks() as control_net:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Control Net Processor

      This tool doesn't exist yet! When it's built it will let you input any image from your phone or computer and process it using any text prompt or combination of trained artist styles / concepts. If you want to play with normal control net without ahx artist concepts check out the link below. [control net](https://huggingface.co/spaces/hysts/ControlNet)
  ''')


    
# -----------------------------------------------------------------------------------------------

# ~~~ TEXTUAL INVERSION TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


with gr.Blocks() as inversion:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Concept Trainer

      ![textual inversion training](https://textual-inversion.github.io/static/images/training/training.JPG)
      
      This external tool lets you train your own new models / concepts from any images you want that will appear automatically be added to the Beta Concepts and Advanced Prompting tabs!

      For now the tool lives on Google Colab, which is Google's free tool for using their GPU's. Someday it might live here on our Hugging Face Space, but the process is a little too demanding for our current resources. To train your own concept visit the link below and follow the instructions and be prepared to wait several hours.

      [textual inversion training tool](https://colab.research.google.com/drive/1FhOpcEjHT7EN53Zv9MFLQTytZp11wjqg#forceEdit=true&sandboxMode=true&scrollTo=ZajfEoWHKAr3)


      Note that you will need a access_token to run this. You can request this on our discord or get your own free one at the link below. [hugging face access token](https://huggingface.co/docs/hub/security-tokens)
  ''')


    
# -----------------------------------------------------------------------------------------------

# ~~~ DREAM BOOTH TAB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


with gr.Blocks() as dream_booth:
  gr.Markdown('''
      # πŸ§‘β€πŸš€ Dream Booth Concept Trainer

      This tool doesn't exist yet! When it's built it will let you train concepts using a process distinct from our current concept training tool which uses textual inversion training. To read more about Dream Booth check out the link below!
      
      [dream booth](https://huggingface.co/spaces/multimodalart/dreambooth-training)
  ''')


    
    
# -----------------------------------------------------------------------------------------------


# tabbed_interface = gr.TabbedInterface([new_welcome, dropdown_tab, beta, inversion, noise_steps, depth_map, control_net, dream_booth], ["Welcome!", "Advanced Prompting", "Beta Concepts", "Concept Trainer", "Noise Steps", "Depth Map", "Control Net", "Dream Booth"])
tabbed_interface = gr.TabbedInterface([new_welcome, dropdown_tab, beta, inversion, noise_steps, control_net], ["Welcome!", "Advanced Prompting", "Beta Concepts", "Concept Trainer", "Noise Steps", "Depth Map", "Control Net", "Dream Booth"])
tabbed_interface.launch()