File size: 1,281 Bytes
fa404c3
fbc1e4c
fa404c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0f947f
 
 
3121067
62b8ae9
fa404c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
os.system("hub install stylepro_artistic==1.0.1")
import gradio as gr
import paddlehub as hub
import numpy as np
from PIL import Image
import cv2 

stylepro_artistic = hub.Module(name="stylepro_artistic")

def inference(content,style):
    result = stylepro_artistic.style_transfer(
    images=[{
        'content': cv2.imread(content.name),
        'styles': [cv2.imread(style.name)]
    }])
    return Image.fromarray(np.uint8(result[0]['data'])[:,:,::-1]).convert('RGB')
    
title = " StyleProNet"
description = "Gradio demo for Parameter-Free Style Projection for Arbitrary Style Transfer. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2003.07694'target='_blank'>Parameter-Free Style Projection for Arbitrary Style Transfer</a> | <a href='https://github.com/PaddlePaddle/PaddleHub' target='_blank'>Github Repo</a></p>"
examples=[['mona1.jpeg','starry.jpeg']]
iface = gr.Interface(inference, inputs=[gr.inputs.Image(type="file",label='content'),gr.inputs.Image(type="file",label='style')], outputs=gr.outputs.Image(type="pil"),enable_queue=True,title=title,article=article,description=description,examples=examples)
iface.launch()