Gertie01 commited on
Commit
39dc0dd
·
verified ·
1 Parent(s): 24a09d7

Rename index.html to app.py

Browse files
Files changed (2) hide show
  1. app.py +346 -0
  2. index.html +0 -310
app.py ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datasets import load_dataset
3
+ from PIL import Image
4
+
5
+ import re
6
+ import os
7
+ import requests
8
+ import uuid
9
+ import base64
10
+
11
+ # --- Model Configuration ---
12
+ MODEL_V1 = "CompVis/stable-diffusion-v1-4"
13
+ MODEL_V2 = "Manojb/stable-diffusion-2-1-base"
14
+ DEVICE = "cuda"
15
+
16
+ from share_btn import community_icon_html, loading_icon_html, share_js
17
+
18
+ word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt")
19
+ word_list = word_list_dataset["train"]['text']
20
+
21
+ is_gpu_busy = False
22
+ def infer(prompt, negative, scale):
23
+ global is_gpu_busy
24
+ for filter in word_list:
25
+ if re.search(rf"\b{filter}\b", prompt):
26
+ print(filter)
27
+ print(prompt)
28
+ raise gr.Error("Unsafe content found. Please try again with different prompts.")
29
+
30
+ images = []
31
+ url = os.getenv('JAX_BACKEND_URL')
32
+ print(url)
33
+ payload = {'prompt': prompt, 'negative_prompt': negative, 'guidance_scale': scale}
34
+ images_request = requests.post(url, json = payload)
35
+ for image in images_request.json()["images"]:
36
+ file_path = f"{uuid.uuid4()}.jpg"
37
+ with open(file_path, "wb") as f:
38
+ f.write(base64.b64decode(image))
39
+ images.append(file_path)
40
+
41
+ return images
42
+
43
+
44
+ css = """
45
+ .gradio-container {
46
+ max-width: 768px !important;
47
+ }
48
+ .gradio-container {
49
+ font-family: 'IBM Plex Sans', sans-serif;
50
+ }
51
+ .gr-button {
52
+ color: white;
53
+ border-color: black;
54
+ background: black;
55
+ }
56
+ input[type='range'] {
57
+ accent-color: black;
58
+ }
59
+ .dark input[type='range'] {
60
+ accent-color: #dfdfdf;
61
+ }
62
+ .container {
63
+ max-width: 730px;
64
+ margin: auto;
65
+ }
66
+ #gallery {
67
+ min-height: 22rem;
68
+ margin-bottom: 15px;
69
+ margin-left: auto;
70
+ margin-right: auto;
71
+ border-bottom-right-radius: .5rem !important;
72
+ border-bottom-left-radius: .5rem !important;
73
+ }
74
+ #gallery>div>.h-full {
75
+ min-height: 20rem;
76
+ }
77
+ .details:hover {
78
+ text-decoration: underline;
79
+ }
80
+ .gr-button {
81
+ white-space: nowrap;
82
+ }
83
+ .gr-button:focus {
84
+ border-color: rgb(147 197 253 / var(--tw-border-opacity));
85
+ outline: none;
86
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
87
+ --tw-border-opacity: 1;
88
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
89
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
90
+ --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
91
+ --tw-ring-opacity: .5;
92
+ }
93
+ #advanced-btn {
94
+ font-size: .7rem !important;
95
+ line-height: 19px;
96
+ margin-top: 12px;
97
+ margin-bottom: 12px;
98
+ padding: 2px 8px;
99
+ border-radius: 14px !important;
100
+ }
101
+ #advanced-options {
102
+ display: none;
103
+ margin-bottom: 20px;
104
+ }
105
+ .footer {
106
+ margin-bottom: 45px;
107
+ margin-top: 35px;
108
+ text-align: center;
109
+ border-bottom: 1px solid #e5e5e5;
110
+ }
111
+ .footer>p {
112
+ font-size: .8rem;
113
+ display: inline-block;
114
+ padding: 0 10px;
115
+ transform: translateY(10px);
116
+ background: white;
117
+ }
118
+ .dark .footer {
119
+ border-color: #303030;
120
+ }
121
+ .dark .footer>p {
122
+ background: #0b0f19;
123
+ }
124
+ .acknowledgments h4{
125
+ margin: 1.25em 0 .25em 0;
126
+ font-weight: bold;
127
+ font-size: 115%;
128
+ }
129
+ .animate-spin {
130
+ animation: spin 1s linear infinite;
131
+ }
132
+ @keyframes spin {
133
+ from {
134
+ transform: rotate(0deg);
135
+ }
136
+ to {
137
+ transform: rotate(360deg);
138
+ }
139
+ }
140
+ #share-btn-container {
141
+ display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;
142
+ margin-top: 10px;
143
+ margin-left: auto;
144
+ }
145
+ #share-btn-container .styler{
146
+ background-color: #000000;
147
+ }
148
+ #share-btn {
149
+ all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;right:0;
150
+ }
151
+ #share-btn * {
152
+ all: unset;
153
+ }
154
+ #share-btn-container div:nth-child(-n+2){
155
+ width: auto !important;
156
+ min-height: 0px !important;
157
+ }
158
+ #share-btn-container .wrap {
159
+ display: none !important;
160
+ }
161
+
162
+ .gr-form{
163
+ flex: 1 1 50%; border-top-right-radius: 0; border-bottom-right-radius: 0;
164
+ }
165
+ #prompt-container{
166
+ gap: 0;
167
+ }
168
+ #prompt-text-input, #negative-prompt-text-input{padding: .45rem 0.625rem}
169
+ #component-16{border-top-width: 1px!important;margin-top: 1em}
170
+ .image_duplication{position: absolute; width: 100px; left: 50px}
171
+ button{height: 100%}
172
+ """
173
+
174
+ block = gr.Blocks(css=css)
175
+
176
+ examples = [
177
+ [
178
+ 'A high tech solarpunk utopia in the Amazon rainforest',
179
+ 'low quality',
180
+ 9
181
+ ],
182
+ [
183
+ 'A pikachu fine dining with a view to the Eiffel Tower',
184
+ 'low quality',
185
+ 9
186
+ ],
187
+ [
188
+ 'A mecha robot in a favela in expressionist style',
189
+ 'low quality, 3d, photorealistic',
190
+ 9
191
+ ],
192
+ [
193
+ 'an insect robot preparing a delicious meal',
194
+ 'low quality, illustration',
195
+ 9
196
+ ],
197
+ [
198
+ "A small cabin on top of a snowy mountain in the style of Disney, artstation",
199
+ 'low quality, ugly',
200
+ 9
201
+ ],
202
+ ]
203
+
204
+
205
+ with block:
206
+ gr.HTML(
207
+ """
208
+ <div style="text-align: center; margin: 0 auto;">
209
+ <div
210
+ style="
211
+ display: inline-flex;
212
+ align-items: center;
213
+ gap: 0.8rem;
214
+ font-size: 1.75rem;
215
+ "
216
+ >
217
+ <svg
218
+ width="0.65em"
219
+ height="0.65em"
220
+ viewBox="0 0 115 115"
221
+ fill="none"
222
+ xmlns="http://www.w3.org/2000/svg"
223
+ >
224
+ <rect width="23" height="23" fill="white"></rect>
225
+ <rect y="69" width="23" height="23" fill="white"></rect>
226
+ <rect x="23" width="23" height="23" fill="#AEAEAE"></rect>
227
+ <rect x="23" y="69" width="23" height="23" fill="#AEAEAE"></rect>
228
+ <rect x="46" width="23" height="23" fill="white"></rect>
229
+ <rect x="46" y="69" width="23" height="23" fill="white"></rect>
230
+ <rect x="69" width="23" height="23" fill="black"></rect>
231
+ <rect x="69" y="69" width="23" height="23" fill="black"></rect>
232
+ <rect x="92" width="23" height="23" fill="#D9D9D9"></rect>
233
+ <rect x="92" y="69" width="23" height="23" fill="#AEAEAE"></rect>
234
+ <rect x="115" y="46" width="23" height="23" fill="white"></rect>
235
+ <rect x="115" y="115" width="23" height="23" fill="white"></rect>
236
+ <rect x="115" y="69" width="23" height="23" fill="#D9D9D9"></rect>
237
+ <rect x="92" y="46" width="23" height="23" fill="#AEAEAE"></rect>
238
+ <rect x="92" y="115" width="23" height="23" fill="#AEAEAE"></rect>
239
+ <rect x="92" y="69" width="23" height="23" fill="white"></rect>
240
+ <rect x="69" y="46" width="23" height="23" fill="white"></rect>
241
+ <rect x="69" y="115" width="23" height="23" fill="white"></rect>
242
+ <rect x="69" y="69" width="23" height="23" fill="#D9D9D9"></rect>
243
+ <rect x="46" y="46" width="23" height="23" fill="black"></rect>
244
+ <rect x="46" y="115" width="23" height="23" fill="black"></rect>
245
+ <rect x="46" y="69" width="23" height="23" fill="black"></rect>
246
+ <rect x="23" y="46" width="23" height="23" fill="#D9D9D9"></rect>
247
+ <rect x="23" y="115" width="23" height="23" fill="#AEAEAE"></rect>
248
+ <rect x="23" y="69" width="23" height="23" fill="black"></rect>
249
+ </svg>
250
+ <h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">
251
+ Stable Diffusion 2.1 Demo
252
+ </h1>
253
+ </div>
254
+ <p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
255
+ Stable Diffusion 2.1 is the latest text-to-image model from StabilityAI. <a style="text-decoration: underline;" href="https://huggingface.co/spaces/stabilityai/stable-diffusion-1">Access Stable Diffusion 1 Space here</a><br>For faster generation and API
256
+ access you can try
257
+ <a
258
+ href="http://beta.dreamstudio.ai/"
259
+ style="text-decoration: underline;"
260
+ target="_blank"
261
+ >DreamStudio Beta</a
262
+ >.</a>
263
+ </p>
264
+ </div>
265
+ """
266
+ )
267
+ with gr.Group():
268
+ with gr.Row(elem_id="prompt-container"):
269
+ with gr.Column(scale=3):
270
+ text = gr.Textbox(
271
+ label="Enter your prompt",
272
+ show_label=False,
273
+ max_lines=1,
274
+ placeholder="Enter your prompt",
275
+ elem_id="prompt-text-input",
276
+ )
277
+ negative = gr.Textbox(
278
+ label="Enter your negative prompt",
279
+ show_label=False,
280
+ max_lines=1,
281
+ placeholder="Enter a negative prompt",
282
+ elem_id="negative-prompt-text-input",
283
+ )
284
+ with gr.Column(scale=1, min_width=150):
285
+ btn = gr.Button("Generate image")
286
+
287
+ gallery = gr.Gallery(
288
+ label="Generated images", show_label=False, elem_id="gallery"
289
+ )
290
+
291
+ with gr.Group(elem_id="container-advanced-btns"):
292
+ #advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
293
+ with gr.Group(elem_id="share-btn-container"):
294
+ community_icon = gr.HTML(community_icon_html)
295
+ loading_icon = gr.HTML(loading_icon_html)
296
+ share_button = gr.Button("Share to community", elem_id="share-btn")
297
+
298
+ with gr.Accordion("Advanced settings", open=False):
299
+ # gr.Markdown("Advanced settings are temporarily unavailable")
300
+ # samples = gr.Slider(label="Images", minimum=1, maximum=4, value=4, step=1)
301
+ # steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=45, step=1)
302
+ guidance_scale = gr.Slider(
303
+ label="Guidance Scale", minimum=0, maximum=50, value=9, step=0.1
304
+
305
+ ex = gr.Examples(examples=examples, fn=infer, inputs=[text, negative, guidance_scale], outputs=[gallery, community_icon, loading_icon, share_button], cache_examples=False)
306
+ ex.dataset.headers = [""]
307
+ negative.submit(infer, inputs=[text, negative, guidance_scale], outputs=[gallery], concurrency_limit=80)
308
+ text.submit(infer, inputs=[text, negative, guidance_scale], outputs=[gallery], concurrency_limit=80)
309
+ btn.click(infer, inputs=[text, negative, guidance_scale], outputs=[gallery], concurrency_limit=80)
310
+
311
+ #advanced_button.click(
312
+ # None,
313
+ # [],
314
+ # text,
315
+ # _js="""
316
+ # () => {
317
+ # const options = document.querySelector("body > gradio-app").querySelector("#advanced-options");
318
+ # options.style.display = ["none", ""].includes(options.style.display) ? "flex" : "none";
319
+ # }""",
320
+ #)
321
+ share_button.click(
322
+ None,
323
+ [],
324
+ [],
325
+ js=share_js,
326
+ )
327
+ gr.HTML(
328
+ """
329
+ <div class="footer">
330
+ <p>Model by <a href="https://huggingface.co/stabilityai" style="text-decoration: underline;" target="_blank">StabilityAI</a> - backend running JAX on TPUs due to generous support of <a href="https://sites.research.google/trc/about/" style="text-decoration: underline;" target="_blank">Google TRC program</a> - Gradio Demo by 🤗 Hugging Face
331
+ </p>
332
+ </div>
333
+ """
334
+ )
335
+ with gr.Accordion(label="License", open=False):
336
+ gr.HTML(
337
+ """<div class="acknowledgments">
338
+ <p><h4>LICENSE</h4>
339
+ The model is licensed with a <a href="https://huggingface.co/Manojb/stable-diffusion-2-1-base/blob/main/LICENSE-MODEL" style="text-decoration: underline;" target="_blank">CreativeML OpenRAIL++</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
340
+ <p><h4>Biases and content acknowledgment</h4>
341
+ Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the <a href="https://laion.ai/blog/laion-5b/" style="text-decoration: underline;" target="_blank">LAION-5B dataset</a>, which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the <a href="https://huggingface.co/CompVis/stable-diffusion-v1-4" style="text-decoration: underline;" target="_blank">model card</a></p>
342
+ </div>
343
+ """
344
+ )
345
+
346
+ block.queue().launch(max_threads=150, show_error=True)
index.html DELETED
@@ -1,310 +0,0 @@
1
- import gradio as gr
2
- import torch
3
- import spaces
4
- from diffusers import DiffusionPipeline
5
- from PIL import Image
6
- from typing import List, Optional, Any
7
-
8
- # --- Model Configuration ---
9
- MODEL_V1 = "CompVis/stable-diffusion-v1-4"
10
- MODEL_V2 = "Manojb/stable-diffusion-2-1-base"
11
- DEVICE = "cuda"
12
-
13
- <!DOCTYPE html>
14
- <html lang="en">
15
- <head>
16
- <meta charset="utf-8" />
17
- <meta
18
- name="viewport"
19
- content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1"
20
- />
21
- # --- Model Configuration ---
22
- MODEL_V1 = "CompVis/stable-diffusion-v1-4"
23
- MODEL_V2 = "Manojb/stable-diffusion-2-1-base"
24
- DEVICE = "cuda"
25
- <script>
26
- window.__gradio_mode__ = "app";
27
- window.gradio_config = {
28
- version: "3.0.26\n",
29
- mode: "blocks",
30
- dev_mode: false,
31
- components: [
32
- {
33
- id: 1,
34
- type: "column",
35
- props: {
36
- type: "column",
37
- variant: "default",
38
- visible: true,
39
- style: {},
40
- },
41
- },
42
- {
43
- id: 2,
44
- type: "markdown",
45
- props: {
46
- value:
47
- '<h1><center>DALL\u00b7E mini by <a href="https://www.craiyon.com/" target="_blank">craiyon.com</a></center></h1>',
48
- name: "markdown",
49
- visible: true,
50
- style: {},
51
- },
52
- },
53
- {
54
- id: 3,
55
- type: "markdown",
56
- props: {
57
- value:
58
- "<center>AI model generating images from any prompt!</center>",
59
- name: "markdown",
60
- visible: true,
61
- style: {},
62
- },
63
- },
64
- {
65
- id: 4,
66
- type: "group",
67
- props: { type: "group", visible: true, style: {} },
68
- },
69
- {
70
- id: 5,
71
- type: "box",
72
- props: { type: "box", visible: true, style: {} },
73
- },
74
- {
75
- id: 6,
76
- type: "row",
77
- props: {
78
- type: "row",
79
- visible: true,
80
- style: { equal_height: true, mobile_collapse: false },
81
- },
82
- },
83
- {
84
- id: 7,
85
- type: "textbox",
86
- props: {
87
- lines: 1,
88
- max_lines: 1,
89
- value: "",
90
- label: "Enter your prompt",
91
- show_label: false,
92
- name: "textbox",
93
- visible: true,
94
- elem_id: "prompt",
95
- style: { container: false },
96
- },
97
- },
98
- {
99
- id: 8,
100
- type: "button",
101
- props: {
102
- value: "Run",
103
- variant: "primary",
104
- name: "button",
105
- visible: true,
106
- style: {},
107
- },
108
- },
109
- {
110
- id: 9,
111
- type: "gallery",
112
- props: {
113
- value: [],
114
- label: "Generated images",
115
- show_label: false,
116
- name: "gallery",
117
- visible: true,
118
- elem_id: "gallery",
119
- style: { grid: [3], height: "auto" },
120
- },
121
- },
122
- {
123
- id: 10,
124
- type: "column",
125
- props: {
126
- type: "column",
127
- variant: "default",
128
- visible: true,
129
- style: {},
130
- },
131
- },
132
- {
133
- id: 11,
134
- type: "button",
135
- props: {
136
- value: "Screenshot",
137
- variant: "secondary",
138
- name: "button",
139
- visible: true,
140
- elem_id: "screenshot",
141
- style: { full_width: true },
142
- },
143
- },
144
- {
145
- id: 12,
146
- type: "markdown",
147
- props: {
148
- value:
149
- '<details>\n<summary>Bias and Limitations</summary>\n<p style=\'line-height: normal; font-size: small\'>\nWhile the capabilities of image generation models are impressive, they may also reinforce or exacerbate societal biases. While the extent and nature of the biases of the DALL\u00b7E mini model have yet to be fully documented, given the fact that the model was trained on unfiltered data from the Internet, it may generate images that contain stereotypes against minority groups. Work to analyze the nature and extent of these limitations is ongoing, and will be documented in more detail in the <a href="https://huggingface.co/Manojb/stable-diffusion-2-1-base" target="_blank">DALL\u00b7E mini model card</a>.\n</p>\n</details>',
150
- name: "markdown",
151
- visible: true,
152
- style: {},
153
- },
154
- },
155
- {
156
- id: 13,
157
- type: "markdown",
158
- props: {
159
- value:
160
- '<p style=\'text-align: center\'>\nNew model available on \ud83d\udd8d\ufe0f <a href="https://www.craiyon.com/" target="_blank">craiyon.com</a>\n</p>',
161
- name: "markdown",
162
- visible: true,
163
- style: {},
164
- },
165
- },
166
- {
167
- id: 14,
168
- type: "markdown",
169
- props: {
170
- value:
171
- '<hr />\n<p style=\'text-align: center\'>\nCreated by <a href="https://twitter.com/borisdayma" target="_blank">Boris Dayma</a> et al. 2021-2022\n<br/>\n<a href="https://huggingface.co/Manojb/stable-diffusion-2-1-base" target="_blank">GitHub</a> | <a href="https://huggingface.co/Manojb/stable-diffusion-2-1-base" target="_blank">Project Report</a>\n<p style=\'text-align: center\'>Powered by Google <a href="https://sites.research.google/trc/" target="_blank">TPU Research Cloud</a>\n</p>',
172
- name: "markdown",
173
- visible: true,
174
- style: {},
175
- },
176
- },
177
- ],
178
- theme: "default",
179
- css: ".container { max-width: 800px; margin: auto; }",
180
- title: "Gradio",
181
- enable_queue: false,
182
- layout: {
183
- id: 0,
184
- children: [
185
- {
186
- id: 1,
187
- children: [
188
- { id: 2 },
189
- { id: 3 },
190
- {
191
- id: 4,
192
- children: [
193
- {
194
- id: 5,
195
- children: [{ id: 6, children: [{ id: 7 }, { id: 8 }] }],
196
- },
197
- { id: 9 },
198
- ],
199
- },
200
- ],
201
- },
202
- {
203
- id: 10,
204
- children: [{ id: 11 }, { id: 12 }, { id: 13 }, { id: 14 }],
205
- },
206
- ],
207
- },
208
- dependencies: [
209
- {
210
- targets: [8],
211
- trigger: "click",
212
- inputs: [7],
213
- outputs: [9],
214
- backend_fn: false,
215
- js: "\n async (text) => {\n try {\n document.querySelector('#screenshot').style.display = 'none';\n response = await fetch('https://bf.pcuenca.net/generate', {\n method: 'POST',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n prompt: text\n })\n });\n response = await response.json()\n let imgs = response.images.map(r => \"data:image/png;base64,\" + r)\n document.querySelector('#screenshot').style.display = 'block';\n return imgs\n } catch (e) {\n alert(\"Too much traffic, please try again.\")\n IMG = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAOVBMVEXg4OB1dXXX19fd3d2EhIR9fX14eHjJycm2trbb29uurq6goKCZmZmIiIiBgYHNzc2np6e8vLySkpKXK8HrAAABuUlEQVR4nO3Z0bKCIBCAYQNFVCzr/R/2nHU6k8KpJi6wZf7vLu1id9gFhKYBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAb249h7pzr5jD29uhospnlfNo4L+boiLKYyZ0iblKYiu/iNER3PTquD9npPgbB98Za0/twH59JVasMtzXo1m+iHny7PrwpysSuebgxCtmOTlkma121l/TFZR2UqXxEebxEO/87QZlZ3inpeCPzVftkojUyJp2OWVgKy23qSsbg8evitBSXkUjHzYN9Is0oeWoYkkUKazsxRYlYKa6ldFSfs7K/8tsnUSLrXHAuG1SOXpp5t1LEiQxSe33ZqDJIC4TdkziRJkRN9J1CXFlpIj7J9RvNSd0kiUj1zSVjyiKr4X5yTRIx0kYlY8oinbzfFSaJWFlJSsaUpZpEqimttNkTOpo9nX4TOqbfdEFM6FgQpW7c8OofSrYo1Wwaq9nG1/NhVc2nbj2HD821kuOgeg7o3hyZBj1Hpo9D7M3K+HeIrSmPeq4Vfl3ruOhpnly9vdyEfa1KLkPF7nr66GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPjcD13rCcC3ILx/AAAAAElFTkSuQmCC\"\n document.querySelector('#screenshot').style.display = 'block';\n return Array(9).fill(IMG)\n }\n }\n ",
216
- status_tracker: null,
217
- queue: null,
218
- api_name: null,
219
- scroll_to_output: false,
220
- show_progress: true,
221
- },
222
- {
223
- targets: [11],
224
- trigger: "click",
225
- inputs: [],
226
- outputs: [],
227
- backend_fn: false,
228
- js: "\n () => {\n const captureElement = document.getElementById(1)\n let bg_color = getComputedStyle(document.querySelector(\"#root .container\"))[\"background-color\"]\n captureElement.style.backgroundColor = bg_color; \n html2canvas(captureElement)\n .then(canvas => {\n canvas.style.display = 'none'\n document.body.appendChild(canvas)\n return canvas\n })\n .then(canvas => {\n const image = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream')\n const a = document.createElement('a')\n const date = new Date()\n const filename = `dallemini_${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}_${date.getHours()}-${date.getMinutes()}-${date.getSeconds()}.png`\n a.setAttribute('download', filename)\n a.setAttribute('href', image)\n a.click()\n canvas.remove()\n })\n }\n ",
229
- status_tracker: null,
230
- queue: null,
231
- api_name: null,
232
- scroll_to_output: false,
233
- show_progress: true,
234
- },
235
- ],
236
- };
237
- </script>
238
-
239
- <link rel="preconnect" href="https://fonts.googleapis.com" />
240
- <link
241
- rel="preconnect"
242
- href="https://fonts.gstatic.com"
243
- crossorigin="anonymous"
244
- />
245
- <link
246
- href="https://fonts.googleapis.com/css?family=Source Sans Pro"
247
- rel="stylesheet"
248
- />
249
- <link
250
- href="https://fonts.googleapis.com/css?family=IBM Plex Mono"
251
- rel="stylesheet"
252
- />
253
- <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
254
- <script
255
- type="module"
256
- crossorigin
257
- src="https://gradio.s3-us-west-2.amazonaws.com/3.0.9b12/assets/index.8eca4ae7.js"
258
- ></script>
259
- <link
260
- rel="stylesheet"
261
- href="https://gradio.s3-us-west-2.amazonaws.com/3.0.9b12/assets/index.cbea297d.css"
262
- />
263
- <style>
264
- #screenshot {
265
- display: none;
266
- }
267
- .container > div > div {
268
- padding: 0.5rem;
269
- }
270
- footer a {
271
- color: rgb(156 163 175) !important;
272
- }
273
- footer img {
274
- display: none !important;
275
- }
276
- </style>
277
- <style id="mofo">
278
- body {
279
- display: none !important;
280
- }
281
- </style>
282
- <script type="text/javascript">
283
- if (
284
- self === top ||
285
- window.location.ancestorOrigins[0] === "https://huggingface.co"
286
- ) {
287
- var mofo = document.getElementById("mofo");
288
- mofo.parentNode.removeChild(mofo);
289
- } else {
290
- top.location = self.location;
291
- }
292
- </script>
293
- </head>
294
-
295
- <body
296
- style="
297
- margin: 0;
298
- padding: 0;
299
- display: flex;
300
- flex-direction: column;
301
- flex-grow: 1;
302
- "
303
- >
304
- <div
305
- id="root"
306
- style="display: flex; flex-direction: column; flex-grow: 1"
307
- ></div>
308
- <script src="html2canvas.js"></script>
309
- </body>
310
- </html>