File size: 1,619 Bytes
25fa405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

import gradio as gr

os.system("bash install.sh")


def inference(content: str, style: str) -> str:
    os.system("cd PAMA && python main.py eval --content " + content + " --style " + style)
    return "PAMA/ics.jpg"


title = "PAMA"
description = (
    "<p style='text-align: center'>"
    "PAMA: Consistent Style Transfer. </br> To use it, simply upload "
    "your images, or click one of the examples to load them.</p>"
)

article = (
    "<p style='text-align: center'>"
    "<a href='https://arxiv.org/abs/2201.02233' target='_blank'>"
    "Consistent Style Transfer</a> | "
    "<a href='https://github.com/luoxuan-cs/PAMA' target='_blank'>"
    "Github Repo</a></p>"
)

examples = [
    ['samples/800px-Hoover_Tower_Stanford_January_2013.jpg',
     'samples/Leger_railway_crossing.jpg'],
    ['samples/800px-Robert_Downey_Jr_2014_Comic_Con_(cropped).jpg',
     'samples/1280px-El_Tres_de_Mayo,_by_Francisco_de_Goya,_from_Prado_thin_black_margin.jpg'],
    ['samples/800px-Taylor_Swift_2_-_2019_by_Glenn_Francis_(cropped)_3.jpg',
     'samples/WLANL_-_andrevanb_-_Falaises_près_de_Pourville,_Claude_Monet,_1882.jpg'],
]


def build_interface() -> gr.Interface:
    return gr.Interface(
        inference,
        inputs=[
            gr.Image(type="filepath", label="Content"),
            gr.Image(type="filepath", label="Style"),
        ],
        outputs=gr.Image(type="filepath", label="Output"),
        title=title,
        description=description,
        article=article,
        examples=examples,
    )


if __name__ == "__main__":
    interface = build_interface()
    interface.launch()