Yntec commited on
Commit
8132215
β€’
1 Parent(s): bd650f6

Create apppybk.txt

Browse files
Files changed (1) hide show
  1. apppybk.txt +75 -0
apppybk.txt ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from random import randint
3
+ from all_models import models
4
+
5
+
6
+
7
+ def load_fn(models):
8
+ global models_load
9
+ models_load = {}
10
+
11
+ for model in models:
12
+ if model not in models_load.keys():
13
+ try:
14
+ m = gr.load(f'models/{model}')
15
+ except Exception as error:
16
+ m = gr.Interface(lambda txt: None, ['text'], ['image'])
17
+ models_load.update({model: m})
18
+
19
+
20
+ load_fn(models)
21
+
22
+
23
+ num_models = 1
24
+ default_models = models[:num_models]
25
+
26
+
27
+
28
+ def extend_choices(choices):
29
+ return choices + (num_models - len(choices)) * ['NA']
30
+
31
+
32
+ def update_imgbox(choices):
33
+ choices_plus = extend_choices(choices)
34
+ return [gr.Image(None, label = m, visible = (m != 'NA')) for m in choices_plus]
35
+
36
+
37
+ def gen_fn(model_str, prompt):
38
+ if model_str == 'NA':
39
+ return None
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
+ with gr.Tab('Printing Press'):
47
+ model_choice2 = gr.Dropdown(models, label = 'Choose a model from the 686 available!', value = models[0], filterable = False)
48
+ txt_input2 = gr.Textbox(label = 'Your prompt:')
49
+
50
+ current_images = 1
51
+ max_images = 6
52
+
53
+ gen_button2 = gr.Button('Generate up to 6 images in up to 3 minutes total')
54
+ stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
55
+ gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
56
+ with gr.Column():
57
+ num_images = gr.Slider(current_images, max_images, value = 1, step = 1, label = 'Number of images')
58
+ output2 = [gr.Image(label = '') for _ in range(6)]
59
+ for i, o in enumerate(output2):
60
+ num_models = num_images
61
+ img_i = gr.Number(i, visible = False)
62
+ num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o, show_progress = False)
63
+ 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)
64
+ stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
65
+ with gr.Row():
66
+ gr.HTML(
67
+ """
68
+ <div class="footer">
69
+ <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!
70
+ </p>
71
+ """
72
+ )
73
+
74
+ demo.queue(concurrency_count = 200)
75
+ demo.launch()