Spaces:
Build error
Build error
abdouramandalil
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
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 |
+
st.title("Image Classification")
|
9 |
+
upload_file = st.sidebar.file_uploader("Upload Radio images", 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 téléchargée.", 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 |
+
predictions = model.predict(image_array)
|
22 |
+
classes = np.argmax(predictions[0])
|
23 |
+
for key, value in classes_p.items():
|
24 |
+
if value == classes:
|
25 |
+
st.title("prediction of image is {}".format(key))
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|