mafoaurelie commited on
Commit
f34c233
·
verified ·
1 Parent(s): df49b28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
8
+ st.title('Image Classification')
9
+ upload_file = st.sidebar.file_uploader('upload a radio image',type=['jpg','jpeg','png','PNG'])
10
+ generate_pred = st.sidebar.button('predict')
11
+ model = tf.keras.models.load_model('best_model.h5')
12
+ classes_p = {'COVID19':0,'NORMAL':1}
13
+
14
+ if upload_file:
15
+ st.image(upload_file,caption='Image Telechargee',use_column_width=True)
16
+ test_image = image.load_img(upload_file,target_size=(64,64))
17
+ image_array = img_to_array(test_image)
18
+ image_array = np.expand_dims(image_array,axis=0)
19
+
20
+ if generate_pred:
21
+ prediction = model.predict(image_array)
22
+ classes = np.argmax(prediction[0])
23
+ for key,value in classes_p.items():
24
+ if value == classes:
25
+ st.title('Prediction of image is {}'.format(key))