Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,18 @@ from transformers import AutoImageProcessor, AutoModelForImageClassification, pi
|
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
|
6 |
-
st.set_page_config(page_title="Détection
|
7 |
|
8 |
@st.cache_resource
|
9 |
def load_model():
|
10 |
-
return pipeline("image-classification", model="
|
11 |
|
12 |
def main():
|
13 |
-
st.title("Détection de
|
14 |
|
15 |
model = load_model()
|
16 |
|
17 |
-
uploaded_file = st.file_uploader("Télécharger une radiographie", type=["jpg", "jpeg", "png"])
|
18 |
|
19 |
if uploaded_file:
|
20 |
image = Image.open(uploaded_file)
|
@@ -24,7 +24,7 @@ def main():
|
|
24 |
with st.spinner("Analyse en cours..."):
|
25 |
try:
|
26 |
result = model(image)
|
27 |
-
st.write(f"
|
28 |
st.write(f"Confiance: {result[0]['score']:.2%}")
|
29 |
except Exception as e:
|
30 |
st.error(f"Erreur: {str(e)}")
|
|
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
|
6 |
+
st.set_page_config(page_title="Détection maladies pulmonaires", layout="wide")
|
7 |
|
8 |
@st.cache_resource
|
9 |
def load_model():
|
10 |
+
return pipeline("image-classification", model="gianlab/swin-tiny-patch4-window7-224-finetuned-lungs-disease")
|
11 |
|
12 |
def main():
|
13 |
+
st.title("Détection de maladies pulmonaires")
|
14 |
|
15 |
model = load_model()
|
16 |
|
17 |
+
uploaded_file = st.file_uploader("Télécharger une radiographie thoracique", type=["jpg", "jpeg", "png"])
|
18 |
|
19 |
if uploaded_file:
|
20 |
image = Image.open(uploaded_file)
|
|
|
24 |
with st.spinner("Analyse en cours..."):
|
25 |
try:
|
26 |
result = model(image)
|
27 |
+
st.write(f"Diagnostic: {result[0]['label']}")
|
28 |
st.write(f"Confiance: {result[0]['score']:.2%}")
|
29 |
except Exception as e:
|
30 |
st.error(f"Erreur: {str(e)}")
|