Spaces:
Runtime error
Runtime error
| from PIL import Image | |
| import tensorflow | |
| import gradio as gr | |
| import numpy as np | |
| from tensorflow.keras.models import load_model | |
| import tensorflow as tf | |
| 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." | |
| article = "<p style='text-align: center'><a href='http://openaccess.thecvf.com/content_cvpr_2018/papers/Chen_CartoonGAN_Generative_Adversarial_CVPR_2018_paper.pdf' target='_blank'>Paper</a></p> <p style='text-align: center'>samples from repo: <img src='https://imgur.com/A9pkBlR.jpg'/><img src='https://imgur.com/s3YO3PB.jpg'/><img src='https://imgur.com/qExudXP.jpg'/><img src='https://imgur.com/q8Udor8.jpg'/><img src='https://imgur.com/Y3JqL3Q.jpg'/><img src='https://imgur.com/qpY0Drt.jpg'/></p>" | |
| examples=[['ny_street.jpg'],['husky_study.jpg'],['tube_london.jpg'],['monalisa.jpg'],['dog-sleepy.gif'],['japan_fuji.jpg']] | |
| gr.Interface(infer, gr.inputs.Image(type="pil"), gr.outputs.Image(type="pil"), title=title,description=description,article=article,enable_queue=True,examples=examples).launch(share=False) |