Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,7 @@ with tab1:
|
|
| 37 |
components.html(
|
| 38 |
"""
|
| 39 |
<div style="position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 15px; color: gray;">
|
| 40 |
-
Tous droits réservés ©
|
| 41 |
</div>
|
| 42 |
""",
|
| 43 |
height=50
|
|
@@ -49,53 +49,41 @@ with tab2:
|
|
| 49 |
st.header("Prédiction")
|
| 50 |
#st.markdown("<h1 style='text-align: center;'>Prédiction</h1>", unsafe_allow_html=True)
|
| 51 |
st.sidebar.header("Paramètre pour la prédiction")
|
| 52 |
-
|
| 53 |
-
upload_files = st.sidebar.file_uploader("Télécharger les fichiers", type=['jpg', 'jpeg', 'png'], accept_multiple_files=True, key="upload")
|
| 54 |
generate_pred = st.sidebar.button("Predict")
|
| 55 |
|
| 56 |
# Main
|
| 57 |
-
if
|
| 58 |
-
#
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
classes = np.argmax(predictions, axis=1)
|
| 78 |
-
labels = [key for key, value in covid_classes.items() if value in classes]
|
| 79 |
-
|
| 80 |
-
# Display results in a table
|
| 81 |
-
st.header("Résultats de la prédiction")
|
| 82 |
-
table_data = []
|
| 83 |
-
for i, (file, label) in enumerate(zip(upload_files, labels)):
|
| 84 |
-
# Resize image for table display
|
| 85 |
-
img = Image.open(file)
|
| 86 |
-
img = img.resize((64, 64))
|
| 87 |
-
table_data.append([f"Image {i+1}", label])
|
| 88 |
-
st.table(table_data)
|
| 89 |
|
| 90 |
components.html(
|
| 91 |
"""
|
| 92 |
<div style="position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 15px; color: gray;">
|
| 93 |
-
Tous droits réservés ©
|
| 94 |
</div>
|
| 95 |
""",
|
| 96 |
height=70
|
| 97 |
)
|
| 98 |
|
|
|
|
| 99 |
with tab3:
|
| 100 |
# Définir les informations de contact
|
| 101 |
name = "TAYAWELBA DAWAI Hesed"
|
|
@@ -121,7 +109,7 @@ with tab3:
|
|
| 121 |
components.html(
|
| 122 |
"""
|
| 123 |
<div style="position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 15px; color: gray;">
|
| 124 |
-
Tous droits réservés ©
|
| 125 |
</div>
|
| 126 |
""",
|
| 127 |
height=20
|
|
|
|
| 37 |
components.html(
|
| 38 |
"""
|
| 39 |
<div style="position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 15px; color: gray;">
|
| 40 |
+
Tous droits réservés © Février 2024 Tayawelba Dawaï Hesed
|
| 41 |
</div>
|
| 42 |
""",
|
| 43 |
height=50
|
|
|
|
| 49 |
st.header("Prédiction")
|
| 50 |
#st.markdown("<h1 style='text-align: center;'>Prédiction</h1>", unsafe_allow_html=True)
|
| 51 |
st.sidebar.header("Paramètre pour la prédiction")
|
| 52 |
+
upload_file = st.sidebar.file_uploader("Télécharger le fichier", type=['jpg', 'jpeg', 'png'], key="upload")
|
|
|
|
| 53 |
generate_pred = st.sidebar.button("Predict")
|
| 54 |
|
| 55 |
# Main
|
| 56 |
+
if upload_file:
|
| 57 |
+
# Display uploaded image
|
| 58 |
+
st.header("Image téléchargée")
|
| 59 |
+
st.image(upload_file, caption="Image", use_column_width=True)
|
| 60 |
+
|
| 61 |
+
# Predict label
|
| 62 |
+
if generate_pred:
|
| 63 |
+
# Preprocess image
|
| 64 |
+
test_image = image.load_img(upload_file, target_size=(64, 64))
|
| 65 |
+
image_array = img_to_array(test_image)
|
| 66 |
+
image_array = np.expand_dims(image_array, axis=0)
|
| 67 |
+
|
| 68 |
+
# Make prediction
|
| 69 |
+
prediction = model.predict(image_array)
|
| 70 |
+
classe = np.argmax(prediction, axis=1)
|
| 71 |
+
label = [key for key, value in covid_classes.items() if value == classe][0]
|
| 72 |
+
|
| 73 |
+
# Display result
|
| 74 |
+
st.header("Résultat de la prédiction")
|
| 75 |
+
st.write(f"L'image est classée comme {label}.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
components.html(
|
| 78 |
"""
|
| 79 |
<div style="position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 15px; color: gray;">
|
| 80 |
+
Tous droits réservés © Février 2024 Tayawelba Dawaï Hesed
|
| 81 |
</div>
|
| 82 |
""",
|
| 83 |
height=70
|
| 84 |
)
|
| 85 |
|
| 86 |
+
|
| 87 |
with tab3:
|
| 88 |
# Définir les informations de contact
|
| 89 |
name = "TAYAWELBA DAWAI Hesed"
|
|
|
|
| 109 |
components.html(
|
| 110 |
"""
|
| 111 |
<div style="position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font-size: 15px; color: gray;">
|
| 112 |
+
Tous droits réservés © Février 2024 Tayawelba Dawaï Hesed
|
| 113 |
</div>
|
| 114 |
""",
|
| 115 |
height=20
|