Delete frontend.py
Browse files- frontend.py +0 -49
frontend.py
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import requests
|
3 |
-
from PIL import Image
|
4 |
-
import io
|
5 |
-
import base64
|
6 |
-
|
7 |
-
st.title("Segmentation d'images")
|
8 |
-
|
9 |
-
# Menu to select an image
|
10 |
-
image_id = st.selectbox(
|
11 |
-
"Choisissez une image",
|
12 |
-
("image1", "image2", "image3")
|
13 |
-
)
|
14 |
-
|
15 |
-
if st.button('Prédire'):
|
16 |
-
response = requests.post("http://127.0.0.1:8000/predict/", json={"image_id": image_id})
|
17 |
-
if response.status_code == 200:
|
18 |
-
result = response.json()
|
19 |
-
annotated_mask = Image.open(io.BytesIO(base64.b64decode(result["annotated_mask"].split(",")[1])))
|
20 |
-
predicted_mask = Image.open(io.BytesIO(base64.b64decode(result["predicted_mask"].split(",")[1])))
|
21 |
-
|
22 |
-
st.image(annotated_mask, caption='Masque Annoté', use_column_width=True)
|
23 |
-
st.image(predicted_mask, caption='Masque Prédit', use_column_width=True)
|
24 |
-
|
25 |
-
st.session_state.annotated_mask = result["annotated_mask"]
|
26 |
-
st.session_state.predicted_mask = result["predicted_mask"]
|
27 |
-
else:
|
28 |
-
st.write("Erreur lors de la prédiction")
|
29 |
-
|
30 |
-
if st.button('Évaluer'):
|
31 |
-
if "annotated_mask" in st.session_state and "predicted_mask" in st.session_state:
|
32 |
-
response = requests.post("http://127.0.0.1:8000/evaluate/", json={
|
33 |
-
"annotated_mask": st.session_state.annotated_mask,
|
34 |
-
"predicted_mask": st.session_state.predicted_mask
|
35 |
-
})
|
36 |
-
|
37 |
-
if response.status_code == 200:
|
38 |
-
result = response.json()
|
39 |
-
iou_score = result["iou_score"]
|
40 |
-
annotated_mask = Image.open(io.BytesIO(base64.b64decode(result["annotated_mask"].split(",")[1])))
|
41 |
-
predicted_mask = Image.open(io.BytesIO(base64.b64decode(result["predicted_mask"].split(",")[1])))
|
42 |
-
|
43 |
-
st.image(annotated_mask, caption='Masque Annoté', use_column_width=True)
|
44 |
-
st.image(predicted_mask, caption='Masque Prédit', use_column_width=True)
|
45 |
-
st.write(f"Score IoU: {iou_score}")
|
46 |
-
else:
|
47 |
-
st.write("Erreur lors de l'évaluation")
|
48 |
-
else:
|
49 |
-
st.write("Veuillez d'abord prédire les masques.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|