Spaces:
Runtime error
Runtime error
dtrejopizzo
commited on
Commit
·
d8d1556
1
Parent(s):
1ed2797
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system("hub install stylepro_artistic==1.0.1")
|
3 |
+
import gradio as gr
|
4 |
+
import paddlehub as hub
|
5 |
+
import numpy as np
|
6 |
+
from PIL import Image
|
7 |
+
import cv2
|
8 |
+
|
9 |
+
stylepro_artistic = hub.Module(name="stylepro_artistic")
|
10 |
+
|
11 |
+
def inference(content,style):
|
12 |
+
result = stylepro_artistic.style_transfer(
|
13 |
+
images=[{
|
14 |
+
'content': cv2.imread(content.name),
|
15 |
+
'styles': [cv2.imread(style.name)]
|
16 |
+
}])
|
17 |
+
return Image.fromarray(np.uint8(result[0]['data'])[:,:,::-1]).convert('RGB')
|
18 |
+
|
19 |
+
title = " StyleProNet"
|
20 |
+
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."
|
21 |
+
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>"
|
22 |
+
examples=[['mona1.jpeg','starry.jpeg']]
|
23 |
+
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)
|
24 |
+
iface.launch()
|