-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (22 loc) · 1.12 KB
/
main.py
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
import streamlit as st
from PIL import Image
import cv2
from YOUR_MODULE_NAME import chexnet, get_array, compute_gradcam, visualize_gradcam, get_predicted_label
def main():
st.title('DICOM Image Prediction with GradCAM')
uploaded_file = st.file_uploader("Upload DICOM file", type=['dcm'])
if uploaded_file is not None:
dcm_img = get_array(uploaded_file)
st.subheader('Original X-ray Image:')
st.image(dcm_img, caption='Original X-ray', use_column_width=True)
# Load your pre-trained model here
model = chexnet() # Modify this according to your implementation
if st.button('Get Predictions'):
predictions = model.predict(dcm_img)
predicted_label = get_predicted_label(predictions, LABELS)
st.write(f"Predicted Label: {predicted_label}")
gradcam_labels = [predicted_label] # Modify this based on your requirement
gradcams = compute_gradcam(model, dcm_img, LABELS, gradcam_labels)
visualize_gradcam(dcm_img, gradcams, LABELS, predictions)
if __name__ == '__main__':
main()