Spaces:
Build error
Build error
import gradio as gr | |
import keras | |
from keras.models import load_model | |
# from keras_contrib.layers.normalization.instancenormalization import InstanceNormalization | |
from tensorflow_addons.layers import InstanceNormalization | |
import matplotlib.pyplot as plt | |
import numpy as np | |
cust = {'InstanceNormalization': InstanceNormalization} | |
model=load_model('g_model_AtoB_002160.h5',cust) | |
path = [['ex1.jpg'], ['ex2.jpg']] | |
def show_preds_image(image_path): | |
A = plt.imread(image_path) | |
A = (A - 127.5) / 127.5 | |
A = np.expand_dims(A,axis=0) | |
B = model.predict(A) | |
B=np.squeeze(B,axis=0) | |
B = (B + 1) / 2.0 | |
return B | |
inputs_image = [ | |
gr.components.Image(type="filepath", label="Input Image"), | |
] | |
outputs_image = [ | |
gr.components.Image(type="numpy", label="Output Image"), | |
] | |
interface_image = gr.Interface( | |
fn=show_preds_image, | |
inputs=inputs_image, | |
outputs=outputs_image, | |
title="photo2monet", | |
examples=path, | |
cache_examples=False, | |
) | |
gr.TabbedInterface( | |
[interface_image], | |
tab_names=['Image inference'] | |
).queue().launch() | |