phenomenon1981 commited on
Commit
e5161ea
1 Parent(s): 71b3b0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +90 -51
app.py CHANGED
@@ -58,13 +58,13 @@ def send_it2(inputs, noise_level, proc1=proc1):
58
  output2 = proc1(prompt_with_noise)
59
  return output2
60
 
61
- def send_it3(inputs, noise_level, proc1=proc1):
62
- prompt_with_noise = add_random_noise(inputs, noise_level)
63
- while queue.qsize() >= queue_threshold:
64
- time.sleep(2)
65
- queue.put(prompt_with_noise)
66
- output3 = proc1(prompt_with_noise)
67
- return output3
68
 
69
  #def send_it4(inputs, noise_level, proc1=proc1):
70
  #prompt_with_noise = add_random_noise(inputs, noise_level)
@@ -106,48 +106,87 @@ def send_it3(inputs, noise_level, proc1=proc1):
106
  #output8 = proc1(prompt_with_noise)
107
  #return output8
108
 
109
-
110
- with gr.Blocks() as myface:
111
- with gr.Row():
112
-
113
- input_text=gr.Textbox(label="Short Prompt")
114
- see_prompts=gr.Button("Magic Prompt")
115
- with gr.Row():
116
-
117
- prompt=gr.Textbox(label="Enter Prompt")
118
- noise_level=gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs.")
119
- run=gr.Button("Generate")
120
-
121
- with gr.Row():
122
- like_message = gr.Button("❤️❤️❤️ Press the Like Button if you enjoy my space! ❤️❤️❤️")
123
- with gr.Row():
124
- output1=gr.Image(label="Dreamlike Diffusion 1.0")
125
- output2=gr.Image(label="Dreamlike Diffusion 1.0")
126
- output3=gr.Image(label="Dreamlike Diffusion 1.0")
127
- #output4=gr.Image(label="Dreamlike Diffusion 1.0")
128
- #with gr.Row():
129
- #output5=gr.Image(label="Dreamlike Diffusion 1.0")
130
- #output6=gr.Image(label="Dreamlike Diffusion 1.0")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  #with gr.Row():
132
- #output7=gr.Image(label="Dreamlike Diffusion 1.0")
133
- #output8=gr.Image(label="Dreamlike Diffusion 1.0")
134
-
135
- see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
136
- run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
137
- run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
138
- run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3])
139
- #run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4])
140
- #run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5])
141
- #run.click(send_it6, inputs=[prompt, noise_level], outputs=[output6])
142
- #run.click(send_it7, inputs=[prompt, noise_level], outputs=[output7])
143
- #run.click(send_it8, inputs=[prompt, noise_level], outputs=[output8])
144
-
145
- with gr.Row():
146
- # other components
147
- article = gr.HTML("""
148
- Demo for <a href="https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0">Dreamlike Diffusion 1.0</a> Stable Diffusion model.
149
- """)
150
-
151
-
152
- myface.launch(enable_queue=True, inline=True)
153
- block.queue(concurrency_count=100)
 
 
 
58
  output2 = proc1(prompt_with_noise)
59
  return output2
60
 
61
+ #def send_it3(inputs, noise_level, proc1=proc1):
62
+ #prompt_with_noise = add_random_noise(inputs, noise_level)
63
+ #while queue.qsize() >= queue_threshold:
64
+ #time.sleep(2)
65
+ #queue.put(prompt_with_noise)
66
+ #output3 = proc1(prompt_with_noise)
67
+ #return output3
68
 
69
  #def send_it4(inputs, noise_level, proc1=proc1):
70
  #prompt_with_noise = add_random_noise(inputs, noise_level)
 
106
  #output8 = proc1(prompt_with_noise)
107
  #return output8
108
 
109
+ css = '''
110
+ #col-container {max-width: 800px; margin-left: auto; margin-right: auto;}
111
+ a {
112
+ color: inherit;
113
+ text-decoration: underline;
114
+ }
115
+ '''
116
+
117
+ with gr.Blocks(css=css) as demo:
118
+ gr.HTML(
119
+ """
120
+ <div style="text-align: center; max-width: 650px; margin: 0 auto;">
121
+ <div>
122
+ <h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
123
+ Dreamlike Diffusion 1.0
124
+ </h1>
125
+ </div>
126
+ <p style="margin-bottom: 10px; font-size: 96%">
127
+ Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs,
128
+ <a href="https://twitter.com/DavidJohnstonxx/">created by Phenomenon1981</a>.
129
+ </p>
130
+ <p style="margin-bottom: 10px; font-size: 98%">
131
+ ❤️ Press the Like Button if you enjoy my space! ❤️</a>.
132
+ </p>
133
+ </div>
134
+ """
135
+ )
136
+ with gr.Column(elem_id="col-container"):
137
+ with gr.Row(variant="compact"):
138
+ input_text = gr.Textbox(
139
+ label="Short Prompt",
140
+ show_label=False,
141
+ max_lines=2,
142
+ placeholder="Enter a basic idea and click 'Magic Prompt'",
143
+ ).style(
144
+ container=False,
145
+ )
146
+ see_prompts = gr.Button("✨ Magic Prompt ✨").style(full_width=False)
147
+
148
+
149
+ with gr.Row(variant="compact"):
150
+ prompt = gr.Textbox(
151
+ label="Enter your prompt",
152
+ show_label=False,
153
+ max_lines=2,
154
+ placeholder="Full Prompt",
155
+ ).style(
156
+ container=False,
157
+ )
158
+ run = gr.Button("Generate Images").style(full_width=False)
159
+
160
+ with gr.Row():
161
+ with gr.Row():
162
+ noise_level = gr.Slider(minimum=0.1, maximum=3, step=0.1, label="Noise Level")
163
+ with gr.Row():
164
+ with gr.Row():
165
+ output1=gr.Image(label="Dreamlike-photoreal-2.0",show_label=False)
166
+ output2=gr.Image(label="Dreamlike-photoreal-2.0",show_label=False)
167
+
168
  #with gr.Row():
169
+ #output1=gr.Image()
170
+
171
+ run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
172
+ run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
173
+ see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
174
+
175
+
176
+ with gr.Row():
177
+ gr.HTML(
178
+ """
179
+ <div class="footer" style="margin-bottom: 45px; margin-top: 15px; text-align: center; border-bottom: 1px solid #e5e5e5;">
180
+ <p style="font-size: .8rem; display: inline-block; padding: 0 10px; transform: translateY(10px); background: #0b0f19;"> Demo for <a href="https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0">Dreamlike Diffusion 1.0</a> Stable Diffusion model
181
+ </p>
182
+ </div>
183
+ <div class="acknowledgments" style="margin: 1.25em 0 .25em 0; font-size: 115%;">
184
+ <p style="margin: 1.25em 0 .25em 0; font-size: 115%;"> Unleash your creative side and generate mesmerizing images with just a few clicks! Enter a spark of inspiration in the "Basic Idea" text box and click the "Magic Prompt" button to elevate it to a polished masterpiece. Make any final tweaks in the "Full Prompt" box and hit the "Generate Images" button to watch your vision come to life. Experiment with the "Noise Level" for a diverse range of outputs, from similar to wildly unique. Let the fun begin!
185
+ </p>
186
+ </div>
187
+ """
188
+ )
189
+
190
+
191
+ demo.queue(concurrency_count=8)
192
+ demo.launch(enable_queue=True, inline=True)