Yntec commited on
Commit
b46ae9a
β€’
1 Parent(s): 5c76889

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -13
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import gradio as gr
2
  from random import randint
3
  from all_models import models
4
 
@@ -40,40 +40,81 @@ def gen_fn(model_str, prompt):
40
  noise = str('') #str(randint(0, 99999999999))
41
  return models_load[model_str](f'{prompt} {noise}')
42
 
43
-
44
-
 
 
 
45
  with gr.Blocks() as demo:
46
  gr.HTML(
47
  """
48
  <div>
49
- <p> <center><img src="https://huggingface.co/Yntec/OpenGenDiffusers/resolve/main/pp.png" style="height:128px; width:482px; padding-top:0px;" span title="Free ai art image generator Printing Press"></center>
50
  </p>
51
  """
52
  )
53
  with gr.Tab('One Image'):
54
- model_choice2 = gr.Dropdown(models, label = 'Choose model', value = models[0], filterable = False)
55
- txt_input2 = gr.Textbox(label = 'Prompt text')
56
 
57
- max_images = 1
58
- num_images = gr.Slider(1, max_images, value = max_images, step = 1, label = 'Number of images (more images coming soon, stay tuned!)')
59
 
60
- gen_button2 = gr.Button('Generate')
61
- stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
62
- gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
63
 
64
  with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  output2 = [gr.Image(label = '') for _ in range(max_images)]
66
 
67
  for i, o in enumerate(output2):
68
  img_i = gr.Number(i, visible = False)
69
  num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o, show_progress = False)
70
- gen_event2 = gen_button2.click(lambda i, n, m, t: gen_fn(m, t) if (i < n) else None, [img_i, num_images, model_choice2, txt_input2], o)
71
  stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
72
  with gr.Row():
73
  gr.HTML(
74
  """
75
  <div class="footer">
76
- <p> Based on the <a href="https://huggingface.co/spaces/derwahnsinn/TestGen">TestGen</a> Space by derwahnsinn, the <a href="https://huggingface.co/spaces/RdnUser77/SpacIO_v1">SpacIO</a> Space by RdnUser77 and Omnibus's Maximum Multiplier!
77
  </p>
78
  """
79
  )
 
1
+ mport gradio as gr
2
  from random import randint
3
  from all_models import models
4
 
 
40
  noise = str('') #str(randint(0, 99999999999))
41
  return models_load[model_str](f'{prompt} {noise}')
42
 
43
+ def gen_fnsix(model_str, prompt):
44
+ if model_str == 'NA':
45
+ return None
46
+ noisesix = str(randint(1941, 2023)) #str(randint(0, 99999999999))
47
+ return models_load[model_str](f'{prompt} {noisesix}')
48
  with gr.Blocks() as demo:
49
  gr.HTML(
50
  """
51
  <div>
52
+ <p> <center><img src="https://huggingface.co/Yntec/OpenGenDiffusers/resolve/main/pp.png" style="height:128px; width:482px; margin-top: -22px; margin-bottom: -44px;" span title="Free ai art image generator Printing Press"></center>
53
  </p>
54
  """
55
  )
56
  with gr.Tab('One Image'):
57
+ model_choice = gr.Dropdown(models, label = 'Choose a model from the 688 available!', value = models[0], filterable = False)
58
+ txt_input = gr.Textbox(label = 'Your prompt:')
59
 
60
+ max_imagesone = 1
61
+ num_imagesone = gr.Slider(1, max_imagesone, value = max_imagesone, step = 1, label = 'Nobody gets to see this label so I can put here whatever I want!', visible = False)
62
 
63
+ gen_button = gr.Button('Generate')
64
+ stop_button = gr.Button('Stop', variant = 'secondary', interactive = False)
65
+ gen_button.click(lambda s: gr.update(interactive = True), None, stop_button)
66
 
67
  with gr.Row():
68
+ output = [gr.Image(label = '') for _ in range(max_imagesone)]
69
+
70
+ for i, o in enumerate(output):
71
+ img_in = gr.Number(i, visible = False)
72
+ num_imagesone.change(lambda i, n: gr.update(visible = (i < n)), [img_in, num_imagesone], o, show_progress = False)
73
+ gen_event = gen_button.click(lambda i, n, m, t: gen_fn(m, t) if (i < n) else None, [img_in, num_imagesone, model_choice, txt_input], o)
74
+ stop_button.click(lambda s: gr.update(interactive = False), None, stop_button, cancels = [gen_event])
75
+ with gr.Row():
76
+ gr.HTML(
77
+ """
78
+ <div class="footer">
79
+ <p> Based on the <a href="https://huggingface.co/spaces/derwahnsinn/TestGen">TestGen</a> Space by derwahnsinn, the <a href="https://huggingface.co/spaces/RdnUser77/SpacIO_v1">SpacIO</a> Space by RdnUser77, Omnibus's Maximum Multiplier, <a href="https://huggingface.co/spaces/Yntec/Diffusion60XX">Diffusion60XX</a> and <a href="https://huggingface.co/spaces/Yntec/ToyWorld">Toy World</a>!
80
+ </p>
81
+ """
82
+ )
83
+ with gr.Tab('Up To Six'):
84
+ model_choice2 = gr.Dropdown(models, label = 'Choose a model from the 688 available!', value = models[0], filterable = False)
85
+ txt_input2 = gr.Textbox(label = 'Your prompt:')
86
+
87
+ max_images = 6
88
+ num_images = gr.Slider(1, max_images, value = max_images, step = 1, label = 'Number of images (decrease them slowly until they match the boxes below)')
89
+
90
+ gen_button2 = gr.Button('Generate up to 6 images in up to 3 minutes total')
91
+ stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
92
+ gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
93
+ gr.HTML(
94
+ """
95
+ <div style="text-align: center; max-width: 1200px; margin: 0 auto;">
96
+ <div>
97
+ <body>
98
+ <div class="center"><p style="margin-bottom: 10px; color: #000000;">Scroll down to see more images (they generate in a random order).</p>
99
+ </div>
100
+ </body>
101
+ </div>
102
+ </div>
103
+ """
104
+ )
105
+ with gr.Column():
106
  output2 = [gr.Image(label = '') for _ in range(max_images)]
107
 
108
  for i, o in enumerate(output2):
109
  img_i = gr.Number(i, visible = False)
110
  num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o, show_progress = False)
111
+ gen_event2 = gen_button2.click(lambda i, n, m, t: gen_fnsix(m, t) if (i < n) else None, [img_i, num_images, model_choice2, txt_input2], o)
112
  stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
113
  with gr.Row():
114
  gr.HTML(
115
  """
116
  <div class="footer">
117
+ <p> Based on the <a href="https://huggingface.co/spaces/derwahnsinn/TestGen">TestGen</a> Space by derwahnsinn, the <a href="https://huggingface.co/spaces/RdnUser77/SpacIO_v1">SpacIO</a> Space by RdnUser77, Omnibus's Maximum Multiplier, <a href="https://huggingface.co/spaces/Yntec/Diffusion60XX">Diffusion60XX</a> and <a href="https://huggingface.co/spaces/Yntec/ToyWorld">Toy World</a>!
118
  </p>
119
  """
120
  )