Franco Astegiano commited on
Commit
67eb3ce
·
unverified ·
1 Parent(s): f3e4954

Update tf_hub_fast_style_transfer_for_arbitrary_styles.py

Browse files
examples/colab/tf_hub_fast_style_transfer_for_arbitrary_styles.py CHANGED
@@ -67,7 +67,7 @@ import matplotlib.pylab as plt
67
  import numpy as np
68
  import tensorflow as tf
69
  import tensorflow_hub as hub
70
-
71
 
72
  # @title Define image loading and visualization functions { display-mode: "form" }
73
 
@@ -154,10 +154,25 @@ is the same as the content image shape.
154
  # Stylize content image with given style image.
155
  # This is pretty fast within a few milliseconds on a GPU.
156
 
157
- outputs = hub_module(tf.constant(content_image), tf.constant(style_image))
158
- stylized_image = outputs[0]
 
 
159
 
160
  # Visualize input images and the generated stylized image.
161
 
162
- show_n([content_image, style_image, stylized_image], titles=['Original content image', 'Style image', 'Stylized image'])
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
 
67
  import numpy as np
68
  import tensorflow as tf
69
  import tensorflow_hub as hub
70
+ import gradio as gr
71
 
72
  # @title Define image loading and visualization functions { display-mode: "form" }
73
 
 
154
  # Stylize content image with given style image.
155
  # This is pretty fast within a few milliseconds on a GPU.
156
 
157
+ def modify(imageinput,style_input):
158
+ outputs = hub_module(tf.constant(imageinput), tf.constant(style_input))
159
+ return outputs[0]
160
+ #stylized_image = outputs[0]
161
 
162
  # Visualize input images and the generated stylized image.
163
 
164
+ #show_n([content_image, style_image, stylized_image], titles=['Original content image', 'Style image', 'Stylized image'])
165
+
166
+ # Gradio app
167
+
168
+ content_image_input = gr.inputs.Image(label="Content Image")
169
+ style_image_input = gr.inputs.Image(shape=(256, 256), label="Style Image")
170
+
171
+ app_interface = gr.Interface(modify,
172
+ inputs=[content_image_input, style_image_input],
173
+ outputs="image",
174
+ title="Fast Neural Style Transfer",
175
+ description="Gradio demo for Fast Neural Style Transfer using a pretrained Image Stylization model from TensorFlow Hub. To use it, simply upload a content image and style image, or click one of the examples to load them. To learn more about the project, please find the references listed below.",
176
+ )
177
+ app_interface.launch()
178