Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,6 @@ logo_image_path = '1.png'
|
|
18 |
st.image(logo_image_path, width=150)
|
19 |
st.title("Automated Abdominal Aortic Aneurysm Detection")
|
20 |
|
21 |
-
# Function to install dependencies
|
22 |
@st.cache_resource
|
23 |
def install_dependencies():
|
24 |
command = "chmod +x install.sh"
|
@@ -27,7 +26,6 @@ def install_dependencies():
|
|
27 |
command = "./install.sh"
|
28 |
subprocess.run(command, shell=True, check=True)
|
29 |
|
30 |
-
# Function to run inference
|
31 |
@st.cache_resource
|
32 |
def run_inference():
|
33 |
command = "chmod +x inference.sh"
|
@@ -53,7 +51,6 @@ def search_file(start_path, target_file):
|
|
53 |
return os.path.join(root, target_file)
|
54 |
return None
|
55 |
|
56 |
-
# Main Streamlit code
|
57 |
def main():
|
58 |
st.write("Upload a ZIP file containing DICOM slices")
|
59 |
uploaded_zip_file = st.file_uploader("Upload a .zip file", type=["zip"])
|
@@ -86,26 +83,35 @@ def main():
|
|
86 |
subdirectory_path = os.path.join(outputs_directory, first_subdirectory)
|
87 |
temp_dicom_dir_path = os.path.join(subdirectory_path, "temp_dicom_dir")
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
largest_slice = search_file(temp_dicom_dir_path, "out.png")
|
92 |
|
93 |
-
|
94 |
-
zip_filename = os.path.join(temp_dir, "outputs.zip")
|
95 |
-
zip_and_download(temp_dicom_dir_path, zip_filename)
|
96 |
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
|
|
|
102 |
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
else:
|
106 |
-
st.error("
|
107 |
else:
|
108 |
-
st.warning("
|
109 |
else:
|
110 |
st.error("Output files not found")
|
111 |
except Exception as e:
|
|
|
18 |
st.image(logo_image_path, width=150)
|
19 |
st.title("Automated Abdominal Aortic Aneurysm Detection")
|
20 |
|
|
|
21 |
@st.cache_resource
|
22 |
def install_dependencies():
|
23 |
command = "chmod +x install.sh"
|
|
|
26 |
command = "./install.sh"
|
27 |
subprocess.run(command, shell=True, check=True)
|
28 |
|
|
|
29 |
@st.cache_resource
|
30 |
def run_inference():
|
31 |
command = "chmod +x inference.sh"
|
|
|
51 |
return os.path.join(root, target_file)
|
52 |
return None
|
53 |
|
|
|
54 |
def main():
|
55 |
st.write("Upload a ZIP file containing DICOM slices")
|
56 |
uploaded_zip_file = st.file_uploader("Upload a .zip file", type=["zip"])
|
|
|
83 |
subdirectory_path = os.path.join(outputs_directory, first_subdirectory)
|
84 |
temp_dicom_dir_path = os.path.join(subdirectory_path, "temp_dicom_dir")
|
85 |
|
86 |
+
dicom_subdirectories = [subdir for subdir in os.listdir(temp_dicom_dir_path)
|
87 |
+
if os.path.isdir(os.path.join(temp_dicom_dir_path, subdir))]
|
|
|
88 |
|
89 |
+
dicom_folder = dicom_subdirectories[0] if dicom_subdirectories else None
|
|
|
|
|
90 |
|
91 |
+
if dicom_folder:
|
92 |
+
dicom_folder_path = os.path.join(temp_dicom_dir_path, dicom_folder)
|
93 |
+
video_path = search_file(dicom_folder_path, "aaa.mp4")
|
94 |
+
image_path = search_file(dicom_folder_path, "diameter_graph.png")
|
95 |
+
largest_slice = search_file(dicom_folder_path, "out.png")
|
96 |
|
97 |
+
if video_path and image_path and largest_slice:
|
98 |
+
zip_filename = os.path.join(temp_dir, "outputs.zip")
|
99 |
+
zip_and_download(dicom_folder_path, zip_filename)
|
100 |
|
101 |
+
st.title("Largest Slice")
|
102 |
+
st.image(largest_slice, use_column_width=True)
|
103 |
+
|
104 |
+
st.title("Video")
|
105 |
+
st.video(video_path, format="video/mp4")
|
106 |
+
|
107 |
+
st.title("Diameter Graph")
|
108 |
+
st.image(image_path, use_column_width=True)
|
109 |
+
else:
|
110 |
+
st.error("Output files not found")
|
111 |
else:
|
112 |
+
st.error("DICOM folder not found")
|
113 |
else:
|
114 |
+
st.warning("Output files not found")
|
115 |
else:
|
116 |
st.error("Output files not found")
|
117 |
except Exception as e:
|