AdritRao commited on
Commit
1f4b167
·
verified ·
1 Parent(s): 2ab9a3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -15,7 +15,6 @@ subprocess_executed = False
15
 
16
  logo_image_path = '1.png'
17
 
18
-
19
  st.image(logo_image_path, width=150)
20
  st.title("Automated Abdominal Aortic Aneurysm Detection")
21
 
@@ -49,6 +48,13 @@ def zip_and_download(directory, zip_filename):
49
  bytes_data = f.read()
50
  st.download_button(label="Download Outputs", data=bytes_data, file_name=zip_filename, mime="application/zip")
51
 
 
 
 
 
 
 
 
52
  # Main Streamlit code
53
  def main():
54
  st.write("Upload a ZIP file containing DICOM slices")
@@ -82,11 +88,15 @@ def main():
82
  subdirectory_path = os.path.join(outputs_directory, first_subdirectory)
83
  temp_dicom_dir_path = os.path.join(subdirectory_path, "temp_dicom_dir")
84
 
85
- video_path = os.path.join(temp_dicom_dir_path, "images/summary/aaa.mp4")
86
- image_path = os.path.join(temp_dicom_dir_path, "images/summary/diameter_graph.png")
87
- largest_slice = os.path.join(temp_dicom_dir_path, "images/summary/out.png")
 
 
 
 
88
 
89
- if os.path.exists(video_path) and os.path.exists(image_path) and os.path.exists(largest_slice):
90
  zip_filename = os.path.join(temp_dir, "outputs.zip")
91
  zip_and_download(temp_dicom_dir_path, zip_filename)
92
 
 
15
 
16
  logo_image_path = '1.png'
17
 
 
18
  st.image(logo_image_path, width=150)
19
  st.title("Automated Abdominal Aortic Aneurysm Detection")
20
 
 
48
  bytes_data = f.read()
49
  st.download_button(label="Download Outputs", data=bytes_data, file_name=zip_filename, mime="application/zip")
50
 
51
+ # Function to search for files in all subdirectories
52
+ def search_file(start_path, target_file):
53
+ for root, _, files in os.walk(start_path):
54
+ if target_file in files:
55
+ return os.path.join(root, target_file)
56
+ return None
57
+
58
  # Main Streamlit code
59
  def main():
60
  st.write("Upload a ZIP file containing DICOM slices")
 
88
  subdirectory_path = os.path.join(outputs_directory, first_subdirectory)
89
  temp_dicom_dir_path = os.path.join(subdirectory_path, "temp_dicom_dir")
90
 
91
+ video_path = search_file(temp_dicom_dir_path, "aaa.mp4")
92
+ image_path = search_file(temp_dicom_dir_path, "diameter_graph.png")
93
+ largest_slice = search_file(temp_dicom_dir_path, "out.png")
94
+
95
+ st.write(f"Video Path: {video_path}")
96
+ st.write(f"Image Path: {image_path}")
97
+ st.write(f"Largest Slice Path: {largest_slice}")
98
 
99
+ if video_path and image_path and largest_slice:
100
  zip_filename = os.path.join(temp_dir, "outputs.zip")
101
  zip_and_download(temp_dicom_dir_path, zip_filename)
102