test5 / app.py
yupikopi's picture
Update app.py
eee0150
raw
history blame
613 Bytes
import keras.backend as K
import gradio as gr
import numpy as np
def psnr(y_true, y_pred):
return -10*K.log(K.mean(K.flatten((y_true - y_pred))**2)) / np.log(10)
from keras.models import load_model
model = load_model("./MyNet.h5", custom_objects={'psnr': psnr, 'val_psnr': psnr})
image = gr.inputs.Image(shape=(256,256))
image = np.asarray(image)
image = image.astype('float32')
image = image / 255.0
decoded_imgs = model.predict(image)
#decoded_imgs.reshape(256,256,3)
#prediction=model.predict(img_4d)[0]
gr.Interface(inputs=image, outputs=decoded_imgs,interpretation='default').launch(debug='True')