Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
from tensorflow.keras.utils import load_img, img_to_array
|
| 5 |
+
from tensorflow.keras.preprocessing import image
|
| 6 |
+
from PIL import Image, ImageOps
|
| 7 |
+
st.title('Image classification')
|
| 8 |
+
upload_file=st.sidebar.file_uploader('upload a radio image',type=['jpg','png','PNG'])
|
| 9 |
+
generate_pred= st.sidebar.button('Predict')
|
| 10 |
+
model=tf.keras.models.load_model('best_model.h5')
|
| 11 |
+
classes_p={'COVID 19':0,'NORMAL':1}
|
| 12 |
+
|
| 13 |
+
if upload_file:
|
| 14 |
+
st.image(upload_file,caption='Image téléchargé',use_column_width=True)
|
| 15 |
+
test_image=image.load_img(upload_file, target_size=(64,64))
|
| 16 |
+
image_array=img_to_array(test_image)
|
| 17 |
+
image_array=np.expand_dims(image_array,axis=0)
|
| 18 |
+
|
| 19 |
+
if generate_pred:
|
| 20 |
+
prediction=model.predict(image_array)
|
| 21 |
+
classes=np.argmax(prediction[0])
|
| 22 |
+
for key,value in classes_p.items():
|
| 23 |
+
if value==classes:
|
| 24 |
+
st.title('Prediction of image is {}'.format(key))
|