abdouramandalil commited on
Commit
17584ed
·
1 Parent(s): 38d8903

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Import Libraries
2
+ import streamlit as st
3
+ import tensorflow as tf
4
+ import numpy as np
5
+ from tensorflow.keras.utils import load_img,img_to_array
6
+ from tensorflow.keras.preprocessing import image
7
+ from PIL import Image,ImageOps
8
+
9
+ #Title
10
+ st.title("Image Classification")
11
+
12
+ #Loader l image
13
+ upload_file = st.sidebar.file_uploader("Telecharger un fichier",
14
+ type = ['jpg','jpeg','png'])
15
+ generate_pred = st.sidebar.button("Predict")
16
+
17
+ model = tf.keras.models.load_model("model.h5")
18
+ covid_classes = {'COVID19':0,'NORMAL':1,'PNEUMONIA':2,'TUBERCULOSIS':3}
19
+
20
+ if upload_file:
21
+ st.image(upload_file,caption="Image téléchargée",use_column_width=True)
22
+ test_image=image.load_img(upload_file,target_size=(64,64))
23
+ image_array = img_to_array(test_image)
24
+ image_array = np.expand_dims(image_array,axis=0)
25
+
26
+ if generate_pred:
27
+ predictions = model.predict(image_array)
28
+ classes = np.argmax(predictions[0])
29
+ for key,value in covid_classes.items():
30
+ if value == classes:
31
+ st.write("The diagnostic is :",key)
32
+