Beasto commited on
Commit
4d437f4
·
1 Parent(s): 91c2f92

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+ import tensorflow as tf
6
+
7
+ def model_out(model_path,img):
8
+ model = tf.keras.models.load_model(model_path)
9
+ img = (img-127.5)/127.5
10
+ img = np.expand_dims(img, 0)
11
+ pred = model.predict(img)
12
+ pred = np.asarray(pred)
13
+ return pred[0]
14
+
15
+ st.title("Xray Image Enhancer 'Doesnt work well' Pix2Pix")
16
+ face_input = st.file_uploader("Image input")
17
+
18
+ if face_input is not None:
19
+ img = Image.open(face_input)
20
+ img = img.resize((256, 256))
21
+ img = np.array(img)
22
+ pred = model_out('XrayEnhancer.h5', img)
23
+ st.image(img, caption="Uploaded Image")
24
+ st.image(((pred + 1) * 127.5).astype(np.uint8), caption="Enhanced Images")