|
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) |
|
|
|
|
|
|
|
|
|
|
|
gr.Interface(inputs=image, outputs=decoded_imgs,interpretation='default').launch(debug='True') |
|
|