File size: 1,064 Bytes
a326b94
aa66005
7b58439
005d8cf
 
07f59cf
aa66005
005d8cf
 
7b58439
005d8cf
aa66005
005d8cf
c1026ff
005d8cf
 
7b58439
 
aa66005
 
 
 
005d8cf
07f59cf
7b58439
aa66005
7b58439
aa66005
 
 
005d8cf
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
from transformers import pipeline
from PIL import Image

@st.cache_resource
def load_model():
    return pipeline("image-classification", model="mrm8488/vit-base-patch16-224_finetuned-pneumothorax", top_k=2)

def main():
    st.title("Détection de Pneumothorax")
    
    model = load_model()
    
    uploaded_file = st.file_uploader("Télécharger une radiographie", type=["jpg", "jpeg", "png"])
    
    if uploaded_file:
        image = Image.open(uploaded_file).convert('RGB')
        resized_image = image.resize((224, 224))
        
        col1, col2 = st.columns(2)
        with col1:
            st.image(resized_image, width=300, caption="Image originale")
        
        if st.button("Analyser"):
            with st.spinner("Analyse en cours..."):
                results = model(resized_image)
                with col2:
                    st.write("Résultats:")
                    for result in results:
                        st.write(f"{result['label']}: {result['score']:.2%}")

if __name__ == "__main__":
    main()