File size: 1,632 Bytes
0bf81ba
8a76135
0bf81ba
 
 
 
 
 
 
 
61a945a
 
 
 
0bf81ba
 
 
8a76135
 
 
 
0bf81ba
 
 
 
 
 
 
61a945a
0bf81ba
 
 
 
 
 
 
 
 
8a76135
0bf81ba
8a76135
99aac23
 
0bf81ba
99aac23
8a76135
 
 
99aac23
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
from pathlib import Path
from itertools import chain

import gdown
# from PIL import Image
# from numpy import asarray

from run import launch

# download
if not Path('./data/esper_demo').is_dir():
    url = 'https://drive.google.com/drive/folders/1pfWN4WwruOuS5uiuPyPFVB9kidlCV7kc'
    gdown.download_folder(url, quiet=False, use_cookies=False, output="./data/")
assert Path('./data/esper_demo').is_dir()

# example image from COCO data
image_urls = {
    # '108953': 'https://farm8.staticflickr.com/7160/6484651991_9d1eaa557a_z.jpg'
    # '394905': 'http://farm5.staticflickr.com/4151/4955575345_6c6bdfae9d_z.jpg',
    '330341': 'https://farm4.staticflickr.com/3018/3451080626_4a43435f4b_z.jpg',
    '396820': 'https://farm1.staticflickr.com/148/351466274_8d7174e11b_z.jpg'
}
images = {}
for k, url in image_urls.items():
    ext = Path(url).suffix
    output = Path(f"data/images/{k}{ext}")
    if not output.is_file():
        output.parent.mkdir(exist_ok=True)
        gdown.download(url, quiet=False, use_cookies=False, output=str(output))
    images[k] = str(output)

'''
for k, v in images.items():
    with Image.open(v) as image:
        # image = asarray(image)
        images[k] = image
'''

prompts = ['blog:', 'dialogue:', 'This is my favorite poem:']

title = 'Demo for ESPER'
description = None
prompt_eg = f'try pretrained styles such as "blog:" or "dialogue:"\n or unseen prompts such as "{prompts[-1]}"'

examples = [[[v, prompt, 20, False] for prompt in prompts]
            for v in images.values()]
examples = list(chain(*examples))

launch(examples, title=title, description=description, prompt_eg=prompt_eg)