Yntec commited on
Commit
4995953
1 Parent(s): b6f3176

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +159 -0
app.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ models = [
7
+ "Yntec/526",
8
+ ]
9
+ current_model = models[0]
10
+
11
+ text_gen1=gr.Interface.load("spaces/daspartho/prompt-extend")
12
+ #text_gen1=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
13
+
14
+ models2=[
15
+ gr.Interface.load(f"models/{models[0]}",live=True,preprocess=False),
16
+ ]
17
+
18
+ def text_it1(inputs,text_gen1=text_gen1):
19
+ go_t1=text_gen1(inputs)
20
+ return(go_t1)
21
+
22
+ def set_model(current_model):
23
+ current_model = models[current_model]
24
+ return gr.update(label=(f"{current_model}"))
25
+
26
+
27
+ def send_it1(inputs, model_choice): #negative_prompt,
28
+ proc1=models2[model_choice]
29
+ output1=proc1(inputs)
30
+ #negative_prompt=negative_prompt
31
+ return(output1)
32
+ css=""""""
33
+
34
+
35
+ with gr.Blocks(css=css) as myface:
36
+ gr.HTML("""
37
+ <div style="text-align: center; max-width: 1200px; margin: 0 auto;">
38
+ <div>
39
+ <style>
40
+ h1 {
41
+ font-size: 6em;
42
+ color: #ffc99f;
43
+ margin-top: 30px;
44
+ margin-bottom: 30px;
45
+ text-shadow: 3px 3px 0 rgba(0, 0, 0, 1) !important;
46
+ }
47
+ h3 {
48
+ color: #ffc99f; !important;
49
+ }
50
+ h4 {
51
+ display: inline-block;
52
+ color: #ffffff !important;
53
+ }
54
+ .wrapper img {
55
+ font-size: 98% !important;
56
+ white-space: nowrap !important;
57
+ text-align: center !important;
58
+ display: inline-block !important;
59
+ color: #ffffff !important;
60
+ }
61
+ .wrapper {
62
+ color: #ffffff !important;
63
+ }
64
+ .gradio-container {
65
+ background-image: linear-gradient(#254150, #1e2f40, #182634) !important;
66
+ color: #ffaa66 !important;
67
+ font-family: 'IBM Plex Sans', sans-serif !important;
68
+ }
69
+ .text-gray-500 {
70
+ color: #ffc99f !important;
71
+ }
72
+ .gr-box {
73
+ background-image: linear-gradient(#182634, #1e2f40, #254150) !important;
74
+ border-top-color: #000000 !important;
75
+ border-right-color: #ffffff !important;
76
+ border-bottom-color: #ffffff !important;
77
+ border-left-color: #000000 !important;
78
+ }
79
+ .gr-input {
80
+ color: #ffc99f; !important;
81
+ background-color: #254150 !important;
82
+ }
83
+ :root {
84
+ --neutral-100: #000000 !important;
85
+ }
86
+ </style>
87
+ <body>
88
+ <div class="center"><h1>Toy World</h1>
89
+ </div>
90
+ </body>
91
+ </div>
92
+ <p style="margin-bottom: 1px; color: #ffaa66;">
93
+ <h3>Fast Diffusion - 520 Stable Diffusion models, but why? For your enjoyment!</h3></p>
94
+ <br><div class="wrapper">2023.10.29 <img src="https://huggingface.co/Yntec/DucHaitenLofi/resolve/main/NEW.webp" alt="NEW!" style="width:32px;height:16px;"> Toys to play with: The models LuckyStrike, YiffyMix, MeinaAlter, AnythingV3-768, SillySymphonies, DreamWorks and DucHaitenLofi have been added!</div>
95
+ <p style="margin-bottom: 1px; font-size: 98%">
96
+ <br><h4>If a model is already loaded each new image takes less than 20 seconds to generate!</h4></p>
97
+ <p style="margin-bottom: 1px; color: #ffffff;">
98
+ <br>If you get <span style="color: #ff0000;">ERROR</span> it's because that model ran out of memory, try again, or wait a minute and try again, have fun!</p>
99
+ </div>
100
+ """)
101
+ with gr.Row():
102
+ with gr.Column(scale=100):
103
+ #Model selection dropdown
104
+ model_name1 = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index", value=current_model, interactive=True)
105
+ with gr.Row():
106
+ with gr.Column(scale=100):
107
+ magic1=gr.Textbox(label="Your Prompt", lines=4) #Positive
108
+ #with gr.Column(scale=100):
109
+ #negative_prompt=gr.Textbox(label="Negative Prompt", lines=1)
110
+ gr.HTML("""<style> .gr-button {
111
+ color: #ffffff !important;
112
+ text-shadow: 1px 1px 0 rgba(0, 0, 0, 1) !important;
113
+ background-image: linear-gradient(#76635a, #d2a489) !important;
114
+ border-radius: 24px !important;
115
+ border: solid 1px !important;
116
+ border-top-color: #ffc99f !important;
117
+ border-right-color: #000000 !important;
118
+ border-bottom-color: #000000 !important;
119
+ border-left-color: #ffc99f !important;
120
+ padding: 6px 30px;
121
+ }
122
+ .gr-button:active {
123
+ color: #ffc99f !important;
124
+ font-size: 98% !important;
125
+ text-shadow: 0px 0px 0 rgba(0, 0, 0, 1) !important;
126
+ background-image: linear-gradient(#d2a489, #76635a) !important;
127
+ border-top-color: #000000 !important;
128
+ border-right-color: #ffffff !important;
129
+ border-bottom-color: #ffffff !important;
130
+ border-left-color: #000000 !important;
131
+ }
132
+ .gr-button:hover {
133
+ filter: brightness(130%);
134
+ }
135
+ </style>""")
136
+ run=gr.Button("Generate Image")
137
+ with gr.Row():
138
+ with gr.Column(style="width=800px"):
139
+ output1=gr.Image(label=(f"{current_model}"))
140
+
141
+
142
+ with gr.Row():
143
+ with gr.Column(scale=50):
144
+ input_text=gr.Textbox(label="Use this box to extend an idea automagically, by typing some words and clicking Extend Idea",lines=2)
145
+ see_prompts=gr.Button("Extend Idea -> overwrite the contents of the `Your Prompt´ box above")
146
+ use_short=gr.Button("Copy the contents of this box to the `Your Prompt´ box above")
147
+ def short_prompt(inputs):
148
+ return(inputs)
149
+
150
+ model_name1.change(set_model,inputs=model_name1,outputs=[output1])
151
+
152
+ run.click(send_it1, inputs=[magic1, model_name1], outputs=[output1])
153
+
154
+ use_short.click(short_prompt,inputs=[input_text],outputs=magic1)
155
+
156
+ see_prompts.click(text_it1,inputs=[input_text],outputs=magic1)
157
+
158
+ myface.queue(concurrency_count=200)
159
+ myface.launch(inline=True, show_api=False, max_threads=400)