File size: 2,222 Bytes
d5f72bc
 
 
 
 
 
 
 
7210c28
d5f72bc
bb852ba
 
 
 
d5f72bc
 
 
41504fb
d5f72bc
 
 
d84ab71
d5f72bc
d84ab71
d5f72bc
d84ab71
d5f72bc
d84ab71
 
d5f72bc
 
d84ab71
d5f72bc
d84ab71
d5f72bc
 
d84ab71
 
 
 
 
 
 
 
 
e5fb5d2
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
from PIL import Image
import torch
import gradio as gr


#from torch.fx import symbolic_trace
device = 'cuda' if torch.cuda.is_available() else 'cpu'

token = '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'

model1 = torch.hub.load('bryandlee/animegan2-pytorch:main','generator',pretrained='face_paint_512_v1',device=device)
model2 = torch.hub.load('bryandlee/animegan2-pytorch:main','generator',pretrained='face_paint_512_v2',device=device)
model3 = torch.hub.load('bryandlee/animegan2-pytorch:main','generator',pretrained='celeba_distill', device=device)
model4 = torch.hub.load('bryandlee/animegan2-pytorch:main','generator',pretrained='paprika',device=device)

face2paint = torch.hub.load(
    'bryandlee/animegan2-pytorch:main', 'face2paint', 
    size=512, device=device,side_by_side=False
)
def inference(img, ver):
    if ver == 'version 1':
        return face2paint(model1,img)
    elif ver == 'version 2':
        return face2paint(model2,img)
    elif ver == 'version 3':
        return face2paint(model3, img)
    elif ver == 'version 4':
        return face2paint(model4, img)


title = 'KNU BrainAI LAB : Face to Paint'

description = '๋งŒํ™”๋กœ ๋ฐ”๋€ ๋‚ด ์–ผ๊ตด์„ ํ™•์ธํ•ด๋ณด์„ธ์š”!'

article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_animegan' alt='visitor badge'></center></p>"
examples=[['์•„์ด์œ .png','version 1-์•„์ด์œ '],['์•ˆ์ƒํƒœ๊ต์ˆ˜๋‹˜.png','version 2-์•ˆ์ƒํƒœ๊ต์ˆ˜๋‹˜'],['์ผ๋ก ๋จธ์Šคํฌ.png','version 3-์ผ๋ก ๋จธ์Šคํฌ'],['ํ˜„๋นˆ.png','version 4-ํ˜„๋นˆ']]



#gr.Interface(inference, [gr.inputs.Image(type="pil"),gr.inputs.Radio(['version 1','version 2','version 3','version 4'], type="value", default='version 2', label='version')],
#gr.outputs.Image(type="pil"),title=title,description=description,article=article,examples=examples,allow_flagging='never',css="body {background-image: url('file=brainai.png')}").launch(share=True)

demo = gr.Interface(
    inference,[gr.Image(type="pil"),gr.Radio(['version 1','version 2','version 3','version 4'],label='version')],outputs="image")
if __name__ == "__main__":
    demo.launch()