File size: 628 Bytes
fdc5e11 90b13c8 fdc5e11 4ac0de6 fdc5e11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import keras.backend as K
import gradio as gr
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})
def predict_input_image(img):
#img_4d=img.reshape(-1,180,180,3)
img_4d=img.reshape(256,256,3)
prediction=model.predict(img_4d)[0]
return {flower_classes[i]: float(prediction[i]) for i in range(5)}
image = gr.inputs.Image(shape=(256,256))
gr.Interface(fn=predict_input_image, inputs=image, outputs=image,interpretation='default').launch(debug='True')
|