Update app.py
Browse files
app.py
CHANGED
@@ -7,15 +7,11 @@ st.set_page_config(page_title="Aide au diagnostic radiologique", layout="wide")
|
|
7 |
|
8 |
def load_models():
|
9 |
models = {
|
10 |
-
'Fracture': "
|
11 |
-
'Pneumothorax': "
|
12 |
-
'Pneumonie': "
|
13 |
}
|
14 |
-
|
15 |
-
loaded_models = {}
|
16 |
-
for name, model_id in models.items():
|
17 |
-
loaded_models[name] = pipeline("image-classification", model=model_id)
|
18 |
-
return loaded_models
|
19 |
|
20 |
@st.cache_resource
|
21 |
def get_models():
|
@@ -24,7 +20,8 @@ def get_models():
|
|
24 |
def main():
|
25 |
st.title("Assistant de diagnostic radiologique")
|
26 |
|
27 |
-
|
|
|
28 |
|
29 |
uploaded_file = st.file_uploader("Télécharger une image radiologique", type=["jpg", "jpeg", "png"])
|
30 |
|
@@ -37,23 +34,32 @@ def main():
|
|
37 |
with col1:
|
38 |
if st.button("Détecter Fracture"):
|
39 |
with st.spinner("Analyse en cours..."):
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
|
44 |
with col2:
|
45 |
if st.button("Détecter Pneumothorax"):
|
46 |
with st.spinner("Analyse en cours..."):
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
with col3:
|
52 |
if st.button("Détecter Pneumonie"):
|
53 |
with st.spinner("Analyse en cours..."):
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
57 |
|
58 |
if __name__ == "__main__":
|
59 |
main()
|
|
|
7 |
|
8 |
def load_models():
|
9 |
models = {
|
10 |
+
'Fracture': pipeline("image-classification", model="stanfordaimi/fracture-detection-vit"),
|
11 |
+
'Pneumothorax': pipeline("image-classification", model="ahmedos/pneumothorax-detection"),
|
12 |
+
'Pneumonie': pipeline("image-classification", model="ahmedos/pneumonia-detection")
|
13 |
}
|
14 |
+
return models
|
|
|
|
|
|
|
|
|
15 |
|
16 |
@st.cache_resource
|
17 |
def get_models():
|
|
|
20 |
def main():
|
21 |
st.title("Assistant de diagnostic radiologique")
|
22 |
|
23 |
+
with st.spinner("Chargement des modèles..."):
|
24 |
+
models = get_models()
|
25 |
|
26 |
uploaded_file = st.file_uploader("Télécharger une image radiologique", type=["jpg", "jpeg", "png"])
|
27 |
|
|
|
34 |
with col1:
|
35 |
if st.button("Détecter Fracture"):
|
36 |
with st.spinner("Analyse en cours..."):
|
37 |
+
try:
|
38 |
+
result = models['Fracture'](image)
|
39 |
+
st.write(f"Résultat: {result[0]['label']}")
|
40 |
+
st.write(f"Confiance: {result[0]['score']:.2%}")
|
41 |
+
except Exception as e:
|
42 |
+
st.error(f"Erreur: {str(e)}")
|
43 |
|
44 |
with col2:
|
45 |
if st.button("Détecter Pneumothorax"):
|
46 |
with st.spinner("Analyse en cours..."):
|
47 |
+
try:
|
48 |
+
result = models['Pneumothorax'](image)
|
49 |
+
st.write(f"Résultat: {result[0]['label']}")
|
50 |
+
st.write(f"Confiance: {result[0]['score']:.2%}")
|
51 |
+
except Exception as e:
|
52 |
+
st.error(f"Erreur: {str(e)}")
|
53 |
|
54 |
with col3:
|
55 |
if st.button("Détecter Pneumonie"):
|
56 |
with st.spinner("Analyse en cours..."):
|
57 |
+
try:
|
58 |
+
result = models['Pneumonie'](image)
|
59 |
+
st.write(f"Résultat: {result[0]['label']}")
|
60 |
+
st.write(f"Confiance: {result[0]['score']:.2%}")
|
61 |
+
except Exception as e:
|
62 |
+
st.error(f"Erreur: {str(e)}")
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
main()
|