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,ImageChops st.title('Image Classification') upload_file = st.sidebar.file_uploader('Upload Ratio Images',type=['jpg','jpeg','png']) generated_pred = st.sidebar.button('Predict') model = tf.keras.models.load_model('model.keras') classes_p = {'Infection_Bacterienne': 0, 'Infection_Covid': 1, 'Infection_Virale': 2, 'Normal': 3} if upload_file: st.image(upload_file,caption='Image telechargee', use_container_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 generated_pred: predictions = model.predict(image_array) classes = np.argmax(predictions[0]) for key,value in classes_p.items(): if value == classes: st.title(f'Prediction file is {key}')