File size: 662 Bytes
993e7ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2c3ad9
993e7ea
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import nst

def style_transfer(content_img, style_img, epochs, style_weight=1e6, content_weight=1):
  return nst.train(
      nst.img_to_matrix(content_img),
      nst.img_to_matrix(style_img),
      nst.generate_noise_image(nst.img_to_matrix(content_img)),
      content_weight,
      style_weight,
      epochs
  )

demo = gr.Interface(
    fn=style_transfer,
    inputs=[gr.Image(type="pil"), gr.Image(type="pil"), gr.Number(value=40, label="Number of Epochs")],
    outputs=gr.Image(type="pil"),
    title="Neural Style Transfer",
    description="Upload a content image and a style image to generate a stylized output.",
)

demo.launch()