Spaces:
Runtime error
Runtime error
File size: 684 Bytes
90d09a3 9beb587 90d09a3 9beb587 90d09a3 9beb587 90d09a3 b7c4948 |
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
import numpy as np
from tensorflow.keras.models import load_model
model = load_model('model')
print(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 CartoonGAN. To use it, simply upload an image."
iface = gr.Interface(infer, gr.inputs.Image(type="pil"), "image",title=title,description=description).launch(share=True)
|