File size: 1,153 Bytes
4265985
8a359f9
a733905
 
4c0ed57
a733905
 
 
 
 
 
4c0ed57
a733905
cf8fb5c
 
a733905
 
cf8fb5c
a733905
 
 
 
cf8fb5c
a733905
 
cf8fb5c
a733905
 
 
cf8fb5c
a733905
 
 
99d610b
a733905
 
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
34
35
36
37
import streamlit as st
from PIL import Image
from transformers import pipeline
import os

# Check if Groq API key is set and load it if available
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
if GROQ_API_KEY:
    from groq import Groq
    client = Groq(api_key=GROQ_API_KEY)
    # Use Groq API here if you want it for predictions or related tasks

# Streamlit setup
st.title("Pneumonia Chest X-ray Image Detection")

# Upload image
uploaded_image = st.file_uploader("Choose a chest X-ray image...", type=["jpg", "jpeg", "png"])

if uploaded_image is not None:
    # Display the image
    image = Image.open(uploaded_image)
    st.image(image, caption="Uploaded X-ray Image", use_column_width=True)

    # Load the Hugging Face model using the pipeline
    pipe = pipeline("image-classification", model="dima806/pneumonia_chest_xray_image_detection")

    # Run prediction
    with st.spinner("Classifying..."):
        prediction = pipe(image)

    # Display results
    st.write(f"Prediction: {prediction[0]['label']}")
    st.write(f"Confidence: {prediction[0]['score']:.4f}")

else:
    st.warning("Please upload a chest X-ray image to begin detection.")