Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import keras.backend as K
|
2 |
+
def psnr(y_true, y_pred):
|
3 |
+
return -10*K.log(K.mean(K.flatten((y_true - y_pred))**2)) / np.log(10)
|
4 |
+
|
5 |
+
from keras.models import load_model
|
6 |
+
model = load_model("C:/Users/owner/Desktop/MyNet.h5", custom_objects={'psnr': psnr, 'val_psnr': psnr})
|
7 |
+
|
8 |
+
def predict_input_image(img):
|
9 |
+
#img_4d=img.reshape(-1,180,180,3)
|
10 |
+
img_4d=img.reshape(256,256,3)
|
11 |
+
prediction=model.predict(img_4d)[0]
|
12 |
+
return {flower_classes[i]: float(prediction[i]) for i in range(5)}
|
13 |
+
|
14 |
+
image = gr.inputs.Image(shape=(256,256))
|
15 |
+
|
16 |
+
gr.Interface(fn=predict_input_image, inputs=image, outputs=image,interpretation='default').launch(debug='True')
|