radpid / app.py
yassonee's picture
Update app.py
aa66005 verified
raw
history blame
1.06 kB
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()