Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,ImageChops
|
| 7 |
+
st.title('Image Classification')
|
| 8 |
+
upload_file = st.sidebar.file_uploader('Upload Ratio Images',type=['jpg','jpeg','png'])
|
| 9 |
+
generated_pred = st.sidebar.button('Predict')
|
| 10 |
+
model = tf.keras.models.load_model('model.keras')
|
| 11 |
+
classes_p = {'Infection_Bacterienne': 0,
|
| 12 |
+
'Infection_Covid': 1,
|
| 13 |
+
'Infection_Virale': 2,
|
| 14 |
+
'Normal': 3}
|
| 15 |
+
|
| 16 |
+
if upload_file:
|
| 17 |
+
st.image(upload_file,caption='Image telechargee', use_container_width =True)
|
| 18 |
+
test_image = image.load_img(upload_file,target_size=(64,64))
|
| 19 |
+
image_array = img_to_array(test_image)
|
| 20 |
+
image_array = np.expand_dims(image_array,axis=0)
|
| 21 |
+
|
| 22 |
+
if generated_pred:
|
| 23 |
+
predictions = model.predict(image_array)
|
| 24 |
+
classes = np.argmax(predictions[0])
|
| 25 |
+
for key,value in classes_p.items():
|
| 26 |
+
if value == classes:
|
| 27 |
+
st.title(f'Prediction file is {key}')
|