| import streamlit as st
|
| from tensorflow.keras.models import load_model
|
| from PIL import Image, ImageOps
|
| from PIL import Image
|
| import numpy as np
|
|
|
| model=load_model('pneumonia.h5')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| def process_image(img):
|
|
|
| img = ImageOps.fit(img, (50, 50), Image.BICUBIC, centering=(0.5, 0.5))
|
|
|
|
|
| img = np.array(img)
|
| if img.ndim == 2:
|
| img = np.expand_dims(img, axis=-1)
|
| img = np.repeat(img, 3, axis=-1)
|
| elif img.ndim == 3 and img.shape[-1] == 1:
|
| img = np.repeat(img, 3, axis=-1)
|
|
|
|
|
| img = img / 255.0
|
|
|
|
|
| img = np.expand_dims(img, axis=0)
|
|
|
| return img
|
|
|
| st.title("Pnömoni tespiti :lungs:")
|
| st.write("Pnömoni olup olmadığını öğrenmek için röntgen filmi resmini yükle")
|
|
|
| file=st.file_uploader('Bir Resim Sec',type=['jpg','jpeg','png'])
|
|
|
| if file is not None:
|
| img=Image.open(file)
|
| st.image(img,caption='yuklenen resim')
|
| image= process_image(img)
|
| prediction=model.predict(image)
|
| predicted_class=np.argmax(prediction)
|
|
|
| class_names=['normal','pneumonia']
|
| st.write(class_names[predicted_class])
|
|
|