File size: 433 Bytes
040810d
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import gradio as gr
import tensorflow as tf
import tensorflow_hub as hub

hub_model = hub.load('https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2')

def stylize(content_image, style_image):
    stylized_image = hub_model(tf.constant(content_image), tf.constant(style_image))[0]
    return tensor_to_image(stylized_image)

iface = gr.Interface(fn=stylize, inputs=["image", "image"], outputs="image")
iface.launch()