lsquaremaster commited on
Commit
6cde33e
1 Parent(s): b6210cf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import tensorflow_hub as hub
4
+ from PIL import Image
5
+
6
+ model = hub.load('https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2')
7
+
8
+ def style_transfer(content_img, style_img):
9
+ content_img = tf.image.resize(tf.convert_to_tensor(content_img,tf.float32)[tf.newaxis,...] / 255.,(512,512),preserve_aspect_ratio=True)
10
+ style_img = tf.convert_to_tensor(style_image,tf.float32)[tf.newaxis,...] / 255.
11
+
12
+ generated_img = model(content_img, style_img)[0]
13
+ return Image.fromarray(np.unit8(generated_img[0]*255))
14
+
15
+
16
+ title = "Neural Style Transfer"
17
+
18
+ interface = gr.Interface(fn=style_transfer,
19
+ inputs=["image", "image"],
20
+ outputs=["image"],
21
+ title=title
22
+ )
23
+
24
+ interface.launch()