File size: 1,078 Bytes
90d09a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PIL import Image
import tensorflow
import gradio as gr
from tensorflow.keras.models import load_model
model = load_model('model')
def infer(img):
  cartoonGAN = model.signatures["serving_default"]
  img = np.array(img.convert("RGB"))
  img = np.expand_dims(img, 0).astype(np.float32) / 127.5 - 1
  out = cartoonGAN(tf.constant(img))['output_1']
  out = ((out.numpy().squeeze() + 1) * 127.5).astype(np.uint8)
  return out

  
title = "CartoonGAN"
description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."

#description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."
iface = gr.Interface(infer, gr.inputs.Image(type="pil"), "image",title=title,description=description)
iface.launch()