File size: 1,183 Bytes
fdc5e11 90b13c8 eee0150 fdc5e11 4ac0de6 fdc5e11 318c3ac e6f39bd 318c3ac e6f39bd 318c3ac ab77ffd 318c3ac 39496ee 318c3ac d0ff199 fdc5e11 318c3ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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})
# γ©γγγγι’ζ°
#def sepia(input_img):
# sepia_img = np.asarray(input_img)
# sepia_img = sepia_img.astype('float32')
# sepia_img = sepia_img / 255.0
# sepia_img = model.predict(sepia_img)
# return sepia_img
def sepia(inp):
inp = inp.reshape((-1, 256, 256, 3))
inp = np.asarray(inp)
inp = inp.astype('float32')
inp = inp / 255.0
sepia_img = model.predict(inp)
return sepia_img
# γ·γ³γγ«γͺUIγδ½ζ
demo = gr.Interface(
fn=sepia,
inputs=gr.Image(shape=(256, 256)),
outputs="image"
).launch()
#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')
|