-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathindex.html
691 lines (642 loc) · 35.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap.min.css" rel="stylesheet" />
<meta name="twitter:card" content="summary_large_image" />
<!-- anon-on -->
<meta name="twitter:site" content="@GoogleAI" />
<!-- anon-off -->
<meta name="twitter:title" content="Muse: Text-To-Image Generation via Masked Generative Transformers" />
<meta name="twitter:description" content="Muse: Text-To-Image Generation via Masked Generative Transformers" />
<meta name="twitter:image" content="https://muse-model.github.io/images/logo/muse_cake_1.jpg" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="jquery.min.js"></script>
<script src="jquery.flip.min.js"></script>
<title>Muse: Text-To-Image Generation via Masked Generative Transformers</title>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-V8HJZTYJKX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-V8HJZTYJKX');
</script>
<body>
<div id="gallery0" style="padding-top: 50px; padding-bottom: 50px; background-color: rgb(245,245,245);">
<center>
<div class="flipcard" id="fig0">
<div class="front">
<figure>
<img src="./images/logo/muse_cake_1.jpg" style="width: 95%; max-width: 512px;">
<figcaption>A birthday cake with the word "Muse" written on it.</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img src="./images/logo/muse_fire.jpg" style="width: 95%; max-width: 512px;">
<figcaption>A fireplace where the flames spell "Muse".</figcaption>
</figure>
</div>
</div>
</center>
<h2 style="text-align: center;"><i>Muse:</i> Text-To-Image Generation via Masked Generative Transformers</h2>
<!-- anon-on -->
<div class="authors">
<p>Huiwen Chang<sup>*</sup>, Han Zhang<sup>*</sup>, Jarred Barber<sup>†</sup>, AJ Maschinot<sup>†</sup>, José Lezama, Lu Jiang,<br> Ming-Hsuan Yang, Kevin Murphy, William T. Freeman, Michael Rubinstein<sup>†</sup>, Yuanzhen Li<sup>†</sup>, Dilip Krishnan<sup>†</sup> </p>
<p class="smaller"><sup>*</sup>Equal contribution. <sup>†</sup>Core contribution.</p>
<center><img src="https://research.google/static/images/google_research_lockup-121987c06c0aa0ab26ca8716a0f2e7945d1cbf82077bbab9f914dac0a0bf099f.svg" alt="Google Research" height=25></center>
</div>
<!-- anon-off -->
</div>
<div class="header_dark_gray">
<h1><i>Muse</i> is a fast, state-of-the-art text-to-image generation and editing model.</h1>
</div>
<div class="abstract">
<div class="inside">
<p class="text">
We present <i>Muse</i>, a text-to-image Transformer model that achieves state-of-the-art image generation performance while being significantly more efficient than diffusion or autoregressive models. Muse is trained on a masked modeling task in discrete token space: given the text embedding extracted from a pre-trained large language model (LLM), Muse is trained to predict randomly masked image tokens. Compared to pixel-space diffusion models, such as Imagen and DALL-E 2, Muse is significantly more efficient due to the use of discrete tokens and requiring fewer sampling iterations; compared to autoregressive models, such as Parti, Muse is more efficient due to the use of parallel decoding. The use of a pre-trained LLM enables fine-grained language understanding, translating to high-fidelity image generation and the understanding of visual concepts such as objects, their spatial relationships, pose, cardinality, etc. Our 900M parameter model achieves a new SOTA on CC3M, with an FID score of 6.06. The Muse 3B parameter model achieves an FID of 7.88 on zero-shot COCO evaluation, along with a CLIP score of 0.32. Muse also directly enables a number of image editing applications without the need to fine-tune or invert the model: inpainting, outpainting, and mask-free editing.
</p>
<!-- anon-on -->
<a class="read-paper" href="https://arxiv.org/abs/2301.00704"><button>Research Paper</button></a>
<!-- anon-off -->
</div>
</div>
<!-- Block 1: System description -->
<div class="header_dark_gray">
<h1>Text-to-image Generation</h1>
<p align=center>Our model generates high-quality images from text prompts <i>fast</i> (1.3s for 512x512 resolution or 0.5s for 256x256 resolution on TPUv4).</p>
</div>
<div class="image_8" id="gallery1">
<div class="flipcard" id="fig0">
<div class="front">
<figure>
<img src="./images/gallery/An abstract, flowery painting_.jpg">
<figcaption>An abstract, flowery painting</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img>
<figcaption>.</figcaption>
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig1">
<div class="front">
<figure>
<img src="./images/gallery/A shallow focus photography of a lamb in a wine glass._1_sr.jpg">
<figcaption>A shallow focus photography of a lamb in a wine glass.</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img />
<figcaption />
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig2">
<div class="front">
<figure>
<img src="./images/gallery/A cake made of macarons in a heart shape_1_sr.jpg">
<figcaption>A cake made of macarons in a heart shape.</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img src="./images/gallery/A cake made of macarons in a heart shape_1_sr.jpg">
<figcaption>A cake made of macarons in a heart shape.</figcaption>
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig3">
<div class="front">
<figure>
<img src="./images/gallery/A tilt shift macro shot of a tiny Christmas town_sr.jpg">
<figcaption>A tilt shift macro shot of a tiny Christmas town</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img src="./images/gallery/A cake made of macarons in a heart shape_1_sr.jpg">
<figcaption>A cake made of macarons in a heart shape.</figcaption>
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig4">
<div class="front">
<figure>
<img src="./images/gallery/An abstract, flowery painting_.jpg">
<figcaption>An abstract, flowery painting</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img src="./images/gallery/An abstract, flowery painting_.jpg">
<figcaption>.</figcaption>
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig5">
<div class="front">
<figure>
<img src="./images/gallery/An abstract, flowery painting_.jpg">
<figcaption>A shallow focus photography of a lamb in a wine glass.</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img />
<figcaption />
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig6">
<div class="front">
<figure>
<img src="./images/gallery/An abstract, flowery painting_.jpg">
<figcaption>.</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img>
<figcaption>.</figcaption>
</figure>
</div>
</div>
<div class="flipcard nomobile" id="fig7">
<div class="front">
<figure>
<img src="./images/gallery/An abstract, flowery painting_.jpg">
<figcaption>A tilt shift macro shot of a tiny Christmas town</figcaption>
</figure>
</div>
<div class="back">
<figure>
<img>
<figcaption>A cake made of macarons in a heart shape.</figcaption>
</figure>
</div>
</div>
</div>
<div class="header_dark_gray">
<h1>Zero-shot, Mask-free editing</h1>
<p align=center>Our model gives us zero-shot, mask-free editing for free by iteratively resampling image tokens conditioned on a text prompt.
</div>
<div class="compositional">
<br>
<div class="text" id="compositional_madeof">
<!-- <h3>Choose a prompt:</h3> -->
<p class="selectable left"><span class="selected">Original</span>
<!-- <br><span>"A cat wearing a hat."</span> -->
<br><span>"A cat wearing a tie."</span>
<br><span>"A dog."</span>
<br><span>"A pig."</span>
<br><span>"A shiba inu."</span>
<br><span>"A rabbit."</span>
<br><span>"A raccoon."</span>
<br><span>"A tiger."</span>
<br><span>"An owl."</span>
</p>
</div>
<br>
<div class="image">
<img src="./images/edit_opt/orig.gif" id="compositional_madeof_img">
</div>
</div>
<div class="header_light_gray">
<h2>Mask-free editing controls multiple objects in an image using only a text prompt.
</h2>
</div>
<div class="edit_grid">
<div class="caption">A croissant next to a latte with a flower latte art.</div>
<div>
<figure>
<figcaption>Original</figcaption>
<img src="images/mfe/18_seed_0_orig_sr.jpg" >
</figure>
</div>
<div>
<figure>
<figcaption>Edited</figcaption>
<img src="images/mfe/18_seed_0_synth_sr.jpg" >
</figure>
</div>
</div>
<div class="edit_grid">
<div class="caption">A bottle of Pinot Grigio next to a glass of white wine and a cork.</div>
<div>
<figure>
<figcaption>Original</figcaption>
<img src="images/mfe/68_seed_1_orig_sr.jpg" >
</figure>
</div>
<div>
<figure>
<figcaption>Edited</figcaption>
<img src="images/mfe/68_seed_1_synth_sr.jpg" >
</figure>
</div>
</div>
<div class="header_dark_gray">
<h1>Zero-shot Inpainting/Outpainting</h1>
<p align=center>Our model gives us mask-based editing (inpainting/outpainting) for free: mask-based editing is equivalent to generation.</p>
</div>
<div class="compositional">
<br>
<div class="text" id="compositional_animals">
<p class="selectable left"><span class="selected">Original (with mask)</span>
<br><span>"New York in the background"</span><br>
<span>"Paris in the background"</span><br>
<span>"San Francisco in the background"</span>
</p>
</div>
<br>
<div class="image">
<img src="./images/inpaint/boston_masked.jpg" id="compositional_animals_img">
</div>
</div>
<div class="edit_grid">
<div class="caption">Hot air balloons.</div>
<div>
<figure>
<figcaption>Original (+mask)</figcaption>
<img src="images/inpaint/greta_orig.jpg">
</figure>
</div>
<div>
<figure>
<figcaption>Edited</figcaption>
<img src="images/inpaint/greta_balloons.jpg">
</figure>
</div>
</div>
<div class="edit_grid">
<div class="caption">Beautiful fall foliage; the gazebo is on a lake</div>
<div>
<figure>
<figcaption>Original (+mask)</figcaption>
<img src="images/inpaint/gazebo_masked.jpg">
</figure>
</div>
<div>
<figure>
<figcaption>Edited</figcaption>
<img src="images/inpaint/gazebo_synth.jpg">
</figure>
</div>
</div>
<div class="header_dark_gray">
<h1>Interactive editing</h1>
</div>
<div class="white">
<figure>
<figcaption><p>Muse's speed and tokenization approach enables real-time interactive editing of images. For these examples, each update is processed in 760ms via a single pass through the base model and 8 passes through the superres model.</p></figcaption>
</figure>
</div>
<div class="content1">
<div>
<figure>
<iframe width="512" height="512" src="https://www.youtube.com/embed/WWrPo9blNvs" title="Muse interactive editing - Wine" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</figure>
</div>
<div>
<figure>
<iframe width="512" height="512" src="https://www.youtube.com/embed/2ITNOvp5oJU" title="Muse editing demo - Shoes" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</figure>
</div>
</div>
<div class="content1">
<div>
<figure>
<iframe width="512" height="512" src="https://www.youtube.com/embed/COLa2huGD4Q" title="Muse interactive editing - Harvard Square" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</figure>
</div>
<div>
<figure>
<iframe width="512" height="512" src="https://www.youtube.com/embed/Rom8v0WgMBc" title="Muse interactive editing - Can" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</figure>
</div>
</div>
<div class="header_dark_gray">
<h1>Model details</h1>
</div>
<div class="white">
<figure>
<img src="./images/pipeline_v4.jpg">
<figcaption><p><i>Muse</i> training pipeline. We feed low resolution and high resolution images into two independent VQGAN tokenizer networks. These tokens are then masked, and low resolution ("base") and high resolution ("superres") transformers are trained to predict masked tokens, conditioned on unmasked tokens and T5 text embeddings.</p></figcaption>
</figure>
</div>
<div class="content1">
<div>
<h1>Contributions</h1>
<ul class="highlights">
<li>We present a state-of-the-art model for text-to-image generation which achieves excellent FID and CLIP scores, which quantitatively measure image generation quality, diversity and alignment with text prompts.</li>
<li>Our model is significantly faster than other comparable models due to the use of a compressed, discrete latent space and parallel decoding.</li>
<li>Our architecture enables out-of-the-box zero-shot capabilities such as inpainting, outpainting, and mask-free image editing.</li>
</ul>
</div>
<div class="right" style="display: flex;">
<table class="pretty" style="align-self: center;">
<caption><i>Muse</i> improves inference time over other models.<br>
<font size=0.5em>
<sup>*</sup>Stable Diffusion times represent the best reported inference times and were not measured internally. The configuration used to achieve FID of 12.63 uses 5x more diffusion steps than what was used for benchmarking, roughly equivalent to 18.5s sampling time.
</font>
</caption>
<tr style="border-bottom: 3px solid rgb(26, 26, 26);">
<th class="fid">Model</th>
<th class="fid"> Resolution</th>
<th class="fid"> Inference<br>Time (↓)</th>
</tr>
<!-- <tr style="border-top: 1px solid rgb(26, 26, 26);"> -->
<!-- <td>Zero-shot COCO</td> -->
<!-- </tr> -->
<tr>
<td class="model">Stable Diffusion 1.4<sup>*</sup></td>
<td class="fid">512x512</td>
<td class="fid">3.7s</td>
</tr>
<tr>
<td class="model">Parti-3B</td>
<td class="fid">256x256</td>
<td class="fid">6.4s</td>
</tr>
<tr>
<td class="model">Imagen</td>
<td class="fid">256x256</td>
<td class="fid">9.1s</td>
</tr>
<tr style="border-bottom: 1px solid ">
<td class="model">Imagen</td>
<td class="fid">1024x1024</td>
<td class="fid">13.3s</td>
</tr>
<tr>
<td class="model" style="font-weight: bold; color: rgb(26, 26, 26);">Muse-3B</td>
<td class="fid">256x256</td>
<td class="fid" style="font-weight: bold; color: rgb(26, 26, 26);">0.5s</td>
</tr>
</tr>
<td class="model" style="font-weight: bold; color: rgb(26, 26, 26);">Muse-3B</td>
<td class="fid">512x512</td>
<td class="fid" style="font-weight: bold; color: rgb(26, 26, 26);">1.3s</td>
</tr>
</table>
</div>
</div>
<div class="content1">
<div class="right" style="display: flex;">
<table class="pretty" style="align-self: center;">
<caption>FID (quality/diversity) and CLIP (text-image alignment) scores measured on zero-shot COCO.</caption>
<tr style="border-bottom: 3px solid rgb(26, 26, 26);">
<th class="fid">Model</th>
<th class="fid">FID (↓)</th>
<th class="fid"> CLIP (↑)</th>
</tr>
<tr>
<td class="model">Stable Diffusion 1.4</td>
<td class="fid">12.63</td>
<td class="fid">-</td>
</tr>
<tr>
<td class="model">Parti-3B</td>
<td class="fid">8.10</td>
<td class="fid">-</td>
</tr>
<tr style="border-bottom: 1px solid ">
<td class="model">Imagen</td>
<td class="fid" style="font-weight: bold; color: rgb(26, 26, 26);">7.27</td>
<td class="fid">0.27</td>
</tr>
<tr style="border-bottom: 3px solid rgb(26, 26, 26);">
<td class="model" style="font-weight: bold; color: rgb(26, 26, 26);">Muse-3B</td>
<td class="fid">7.88</td>
<td class="fid" style="font-weight: bold; color: rgb(26, 26, 26);">0.32</td>
</tr>
</table>
</div>
</div>
<!-- anon-on -->
<div class="content">
<h1>Special Thanks</h1>
<p class="smaller" style="text-align: justify;">We thank William Chan, Chitwan Saharia, and Mohammad Norouzi for providing us training datasets, various evaluation codes, website templates and generous suggestions. Jay Yagnik, Rahul Sukthankar, Tom Duerig and David Salesin provided enthusiastic support of this project for which we are grateful. We thank Victor Gomes and Erica Moreira for infrastructure support, Jing Yu Koh and Jason Baldridge for dataset, model and evaluation discussions and feedback on the paper, Mike Krainin for model speedup discussions, JD Velasquez for discussions and insights, Sarah Laszlo, Kathy Meier-Hellstern, and Rachel Stigler for assisting us with the publication process, Andrew Bunner, Jordi Pont-Tuset, and Shai Noy for help on internal demos, David Fleet, Saurabh Saxena, Jiahui Yu, and Jason Baldridge for sharing Imagen and Parti speed metrics.</p>
</div>
<!-- anon-off -->
<script type="text/javascript">
logo_images = [
{"src": "./images/logo/muse_cake_1.jpg",
"caption": "A birthday cake with \"Muse\" written on it."},
{"src": "./images/logo/muse_fire.jpg",
"caption": "A fireplace where the word \"Muse\" is spelled in the flames."},
{"src": "./images/logo/muse_fountain_pen.jpg",
"caption": "The word \"Muse\" drawn fluently on paper with a fountain pen."},
{"src": "./images/logo/muse_cupcakes.jpg",
"caption": "a large array of colorful cupcakes, arranged on a maple table to spell \"Muse\""},
//{"src": "./images/logo/muse_aurora.jpg",
//"caption": "The word \"Muse\" written in the night sky, reflected on a lake. The Aurora Borealis is in the background."},
//{"src": "./images/logo/muse_stars.jpg",
//"caption": "A constellation in the night sky that spells out the word \"Muse\"."},
{"src": "./images/logo/muse_latte.jpg",
"caption": "A latte with \"Muse\" written in latte art"},
{"src": "./images/logo/muse_corgi.jpg",
"caption": "A Welsh corgi holding a sign in its mouth that says \"Muse\"."},
{"src": "./images/logo/muse_fish.jpg",
"caption": "A school of fish swirling around in the ocean to spell the letters \"Muse\"."},
{"src": "./images/logo/muse_van_gogh.jpg",
"caption": "The word \"Muse\" painted on canvas by Vincent van Gogh."}
];
gallery_images = [{"src": "./images/gallery/A real flamingo reading a large open book. a big stack of books is piled up next to it. dslr photograph._1_sr.jpg", "caption": "A real flamingo reading a large open book. a big stack of books is piled up next to it. dslr photograph."}, {"src": "./images/gallery/A rabbit playing the violin.jpg", "caption": "A rabbit playing the violin"}, {"src": "./images/gallery/Three elephants standing ontop of each other._sr.jpg", "caption": "Three elephants standing ontop of each other."}, {"src": "./images/gallery/A striking photo of a lighthouse at sunset..jpg", "caption": "A striking photo of a lighthouse at sunset."}, {"src": "./images/gallery/A cat and a dog. Canon camera. 10mm lens_5_sr.jpg", "caption": "A cat and a dog. Canon camera. 10mm lens"}, {"src": "./images/gallery/High-contrast image of the word \u201cWOMBAT\u201d writtenwith thick colored graffiti letters on a white wall with dramatic splashes of paint_sr.jpg", "caption": "High-contrast image of the word \u201cWOMBAT\u201d writtenwith thick colored graffiti letters on a white wall with dramatic splashes of paint"}, {"src": "./images/gallery/A bear riding a bicycle, with a bird perched on the handlebars._1_sr.jpg", "caption": "A bear riding a bicycle, with a bird perched on the handlebars."}, {"src": "./images/gallery/A surrealist painting of a robot making coffee..jpg", "caption": "A surrealist painting of a robot making coffee."}, {"src": "./images/gallery/A cake made of macarons in a heart shape_1_sr.jpg", "caption": "A cake made of macarons in a heart shape"}, {"src": "./images/gallery/An abstract, flowery painting_.jpg", "caption": "An abstract, flowery painting"}, {"src": "./images/gallery/A painting of a canal in Venice.jpg", "caption": "A painting of a canal in Venice"}, {"src": "./images/gallery/The New York skyline, with the great pyramid in the foreground and Mount Everest in the background._sr.jpg", "caption": "The New York skyline, with the great pyramid in the foreground and Mount Everest in the background."}, {"src": "./images/gallery/A shallow focus photography of a lamb in a wine glass._1_sr.jpg", "caption": "A shallow focus photography of a lamb in a wine glass."}, {"src": "./images/gallery/An art gallery displaying Monet paintings. The art gallery is flooded. Robots are going around the art gallery using paddle boards.jpg", "caption": "An art gallery displaying Monet paintings. The art gallery is flooded. Robots are going around the art gallery using paddle boards"}, {"src": "./images/gallery/A close up, sharp photo of a pink flower..jpg", "caption": "A close up, sharp photo of a pink flower."}, {"src": "./images/gallery/A photo of a panda doing yoga on a yoga mat..jpg", "caption": "A photo of a panda doing yoga on a yoga mat."}, {"src": "./images/gallery/A cat playing a game of chess against itself. Hyper sharp. Award winning. Canon camera. 10mm lens_9_sr.jpg", "caption": "A cat playing a game of chess against itself. Hyper sharp. Award winning. Canon camera. 10mm lens"}, {"src": "./images/gallery/A cake made of macarons in a unicorn shape_1_sr.jpg", "caption": "A cake made of macarons in a unicorn shape"}, {"src": "./images/gallery/Portrait of a well-dressed raccoon, oil painting in the styleof Rembrandt_sr.jpg", "caption": "Portrait of a well-dressed raccoon, oil painting in the styleof Rembrandt"}, {"src": "./images/gallery/Two cats doing research_7_sr.jpg", "caption": "Two cats doing research"}, {"src": "./images/gallery/A large present with a red rib-bon to the left of a Christmastree._sr.jpg", "caption": "A large present with a red rib-bon to the left of a Christmastree."}, {"src": "./images/gallery/An artistic black and white street photograph of a French cafe.jpg", "caption": "An artistic black and white street photograph of a French cafe"}, {"src": "./images/gallery/Manhattan skyline made out of bread..jpg", "caption": "Manhattan skyline made out of bread."}, {"src": "./images/gallery/A tilt shift macro shot of a tiny Christmas town_sr.jpg", "caption": "A tilt shift macro shot of a tiny Christmas town"}, {"src": "./images/gallery/A photograph of the inside of a subway train. There are raccoons sitting on the seats. One of them is reading a newspaper. The window shows the city in the background._sr.jpg", "caption": "A photograph of the inside of a subway train. There are raccoons sitting on the seats. One of them is reading a newspaper. The window shows the city in the background."}, {"src": "./images/gallery/Two cups of coffee, one with latte art of yin yang symbol. The other has latter art of a heart._.jpg", "caption": "Two cups of coffee, one with latte art of yin yang symbol. The other has latter art of a heart."}, {"src": "./images/gallery/Rainbow coloured penguin_2_sr.jpg", "caption": "Rainbow coloured penguin"}, {"src": "./images/gallery/A cake made of macarons in a pineapple shape_1_sr.jpg", "caption": "A cake made of macarons in a pineapple shape"}, {"src": "./images/gallery/A high contrast portrait photo of a fluffy hamster wearing an orange beanie and sunglasses holding a sign that says _Let's PAINT!__2_sr.jpg", "caption": "A high contrast portrait photo of a fluffy hamster wearing an orange beanie and sunglasses holding a sign that says "}, {"src": "./images/gallery/A futuristic city with flying cars._1_sr.jpg", "caption": "A futuristic city with flying cars."}, {"src": "./images/gallery/Two baseballs to the left of three tennis balls._sr.jpg", "caption": "Two baseballs to the left of three tennis balls."}, {"src": "./images/gallery/A ballet dancer made from rope..jpg", "caption": "A ballet dancer made from rope."}, {"src": "./images/gallery/A fluffy baby sloth with a knitted hat trying to figure out a laptop, cluse up..jpg", "caption": "A fluffy baby sloth with a knitted hat trying to figure out a laptop, cluse up."}, {"src": "./images/gallery/The saying 'BE EXCELLENT TO EACH OTHER' written in a stained glass window._sr.jpg", "caption": "The saying 'BE EXCELLENT TO EACH OTHER' written in a stained glass window."}, {"src": "./images/gallery/A portrait of a man wearing sunglasses and a business suit, painting in pop art style._sr.jpg", "caption": "A portrait of a man wearing sunglasses and a business suit, painting in pop art style."}];
lastCardFlippedIdx = {
gallery0: -1,
gallery1: -1,
};
lastCardFlippedLastSwapTime = {
gallery0: -1,
gallery1: -1,
};
$(".flipcard").flip({
trigger: "manual",
reverse: false,
});
function checkIfImageIsVisible(name, image) {
numCards = $(name + " .flipcard:visible").size();
for (var cardIdx = 0; cardIdx < numCards; ++cardIdx) {
var isFlipped = $(name + " #fig" + cardIdx).data("flip-model").isFlipped;
if (!isFlipped) {
src = $(name + " #fig" + cardIdx + " div.front figure img").attr("src")
} else {
src = $(name + " #fig" + cardIdx + " div.back figure img").attr("src")
}
if (image.src == src) {
return true;
}
}
return false;
}
function getNextImage(name) {
// different galleries have different sources of imagery.
if (name == "#gallery0") {
img_src = logo_images;
} else {
img_src = gallery_images;
}
while (true) {
randomImageIdx = Math.floor(Math.random() * img_src.length);
if (!checkIfImageIsVisible(name, img_src[randomImageIdx])) {
return img_src[randomImageIdx];
}
}
}
function randomSwapImageWithId(name, randomCardIdx) {
numCards = $(name + " .flipcard:visible").size();
image = getNextImage(name);
const d = new Date();
let currentTime = d.getTime();
lastCardFlippedIdx[name] = randomCardIdx;
lastCardFlippedLastSwapTime[name] = currentTime;
var isFlipped = $(name + " #fig" + randomCardIdx).data("flip-model").isFlipped;
if (!isFlipped) {
$(name + " #fig" + randomCardIdx + " div.back figure img").attr("src", image.src)
$(name + " #fig" + randomCardIdx + " div.back figure figcaption").text(image.caption)
} else {
$(name + " #fig" + randomCardIdx + " div.front figure img").attr("src", image.src)
$(name + " #fig" + randomCardIdx + " div.front figure figcaption").text(image.caption)
}
$(name + " #fig" + randomCardIdx).flip("toggle");
}
function randomSwapImage(name) {
numCards = $(name + " .flipcard:visible").size();
const d = new Date();
if (d.getTime() - lastCardFlippedIdx[name] < 5000) {
setTimeout(randomSwapImage, 1000, name);
return;
}
do {
randomCardIdx = Math.floor(Math.random() * numCards);
if (numCards == 1) {
break;
}
} while (randomCardIdx == lastCardFlippedIdx[name]);
randomSwapImageWithId(name, randomCardIdx);
setTimeout(randomSwapImage, 3000, name);
}
setTimeout(randomSwapImage, 6000, "#gallery0");
function setupGallery1(id) {
randomSwapImageWithId("#gallery1", id);
$("#gallery1 #fig" + id).click(
function() {
randomSwapImageWithId("#gallery1", id);
}
);
}
for (id = 0; id < 8; id ++) {
setupGallery1(id);
}
$("#gallery0 #fig0").click(
function() {
randomSwapImageWithId("#gallery0", 0);
}
);
setTimeout(randomSwapImage, 1000, "#gallery1");
</script>
<script type="text/javascript">
compositionalAnimalsManualClicked = false;
compositionalMadeOfManualClicked = false;
comp_files = {
"Original (with mask)": "./images/inpaint/boston_masked.jpg",
"\"New York in the background\"": "./images/inpaint/boston_nyc.jpg",
"\"Paris in the background\"": "./images/inpaint/boston_paris.jpg",
"\"San Francisco in the background\"": "./images/inpaint/boston_sf.jpg"
}
function updateComposition(name) {
var compositionSpans = $(name + " p span.selected").map(function() {
return $(this).text();
}).get();
var compositionText = "";
for (var compositionSpansIdx = 0; compositionSpansIdx < compositionSpans.length; ++compositionSpansIdx) {
if (compositionSpansIdx > 0) {
compositionText += " ";
}
compositionText += compositionSpans[compositionSpansIdx];
}
if (name == "#compositional_madeof") {
if (compositionText == "Original") {
$(name + "_img").attr("src", "./images/edit_opt/orig.gif")
} else {
// Generate a random index that is not the one already selected
randImgIdx = "/"; // something guaranteed to be in the path
cur_src = $(name + "_img").attr("src");
while (cur_src.search(randImgIdx) != -1) {
randImgIdx = Math.floor(Math.random() * 4);
}
first_space = compositionText.search(" ");
file = compositionText.slice(first_space + 1, -2).replaceAll(" ", "-");
$(name + "_img").attr("src", "./images/edit_opt/" + file + "_" + randImgIdx + ".gif")
}
} else if (name == "#compositional_animals") {
randImgIdx = Math.floor(Math.random() * 4);
$(name + "_img").attr("src", comp_files[compositionText]);
}
}
function randomComposition(name) {
if (name == "#compositional_animals" && compositionalAnimalsManualClicked == true) {
compositionalAnimalsManualClicked = false;
setTimeout(randomComposition, 4000, name);
return;
} else if (name == "#compositional_madeof" &&
compositionalMadeOfManualClicked == true) {
compositionalMadeOfManualClicked = false;
setTimeout(randomComposition, 4000, name);
return;
}
var compositionPs = $(name + " p.selectable").toArray();
var compositionOptions = [];
for (var i = 0; i < compositionPs.length; ++i) {
var compositionSpanSelected = $(compositionPs[i]).children("span.selected");
var compositionSpans = $(compositionPs[i]).children("span").not("span.selected").toArray();
for (var j = 0; j < compositionSpans.length; ++j) {
compositionOption = {
"p": compositionPs[i],
"span_selected": compositionSpanSelected,
"span_option": $(compositionSpans[j])
};
compositionOptions.push(compositionOption);
}
}
randomCompositionOptionIdx = Math.floor(Math.random() * compositionOptions.length);
randomCompositionOption = compositionOptions[randomCompositionOptionIdx];
randomCompositionOption.span_selected.toggleClass("selected");
randomCompositionOption.span_option.toggleClass("selected");
updateComposition(name);
setTimeout(randomComposition, 4000, name);
}
$("#compositional_animals p.selectable span").click(function() {
$(this).siblings().removeClass("selected");
$(this).addClass("selected");
updateComposition("#compositional_animals");
compositionalAnimalsManualClicked = true;
});
$("#compositional_madeof_img").click(function() {
updateComposition("#compositional_madeof");
compositionalAnimalsManualClicked = true;
});
$("#compositional_madeof p.selectable span").click(function() {
$(this).siblings().removeClass("selected");
$(this).addClass("selected");
updateComposition("#compositional_madeof");
compositionalMadeOfManualClicked = true;
});
<!-- setTimeout(randomComposition, 2000, "#compositional_animals"); -->
<!-- setTimeout(randomComposition, 4000, "#compositional_madeof"); -->
</script>
<script src="bootstrap.bundle.min.js"></script>
</body>
</html>