File size: 1,035 Bytes
941be86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

import streamlit as st
import tensorflow as tf
import numpy as np
from tensorflow.keras.utils import load_img, img_to_array 
from tensorflow.keras.preprocessing import image
from PIL import Image, ImageOps
st.title("Image Classification")
upload_file = st.sidebar.file_uploader("Upload Radio images", type = ['jpg','jpeg','png','PNG'])
generate_pred = st.sidebar.button("predict")
model = tf.keras.models.load_model('best_model.h5')
classes_p = {'COVID19': 0, 'NORMAL': 1}

if upload_file:
    st.image(upload_file, caption="Image téléchargée.", use_column_width=True)
    test_image=image.load_img(upload_file,target_size=(64,64))
    image_array = img_to_array(test_image)
    image_array = np.expand_dims(image_array, axis=0)

    if generate_pred:
        predictions = model.predict(image_array)
        classes = np.argmax(predictions[0])
        for key, value in classes_p.items():
            if value == classes:
                st.title("prediction of image is {}".format(key))