AdritRao commited on
Commit
36ee72b
·
1 Parent(s): 20665dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -33
app.py CHANGED
@@ -96,36 +96,49 @@ if uploaded_zip_file is not None:
96
  st.error(f"Error: {str(e)}")
97
 
98
  if st.button("Analyze"):
99
- run_inference()
100
-
101
- # Assuming the 'outputs' directory is located at "/home/user/app/C2C/comp2comp/outputs"
102
- outputs_directory = "/home/user/app/C2C/outputs"
103
-
104
- # Get a list of subdirectories inside the 'outputs' directory
105
- subdirectories = [subdir for subdir in os.listdir(outputs_directory)
106
- if os.path.isdir(os.path.join(outputs_directory, subdir))]
107
-
108
- # Use the first (or only) subdirectory, or None if there are no subdirectories
109
- first_subdirectory = subdirectories[0] if subdirectories else None
110
-
111
- if first_subdirectory:
112
- # Construct the paths to the video and image files inside the first subdirectory
113
- video_path = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/aaa.mp4")
114
- image_path = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/diameter_graph.png")
115
- largest_slice = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/out.png")
116
-
117
- if os.path.exists(largest_slice):
118
- st.title("Largest Slice")
119
- st.image(largest_slice, use_column_width=True)
120
-
121
- # Display the video generated by the inference script
122
- if os.path.exists(video_path):
123
- st.title("Video")
124
- st.video(video_path, format="video/mp4")
125
-
126
- # Display the image generated by the inference script
127
- if os.path.exists(image_path):
128
- st.title("Diameter Graph")
129
- st.image(image_path, use_column_width=True)
130
- else:
131
- st.warning("No subdirectories or folders found inside the 'outputs' directory.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  st.error(f"Error: {str(e)}")
97
 
98
  if st.button("Analyze"):
99
+ run_inference()
100
+
101
+ # Assuming the 'outputs' directory is located at "/home/user/app/C2C/comp2comp/outputs"
102
+ outputs_directory = "/home/user/app/C2C/outputs"
103
+
104
+ # Get a list of subdirectories inside the 'outputs' directory
105
+ subdirectories = [subdir for subdir in os.listdir(outputs_directory)
106
+ if os.path.isdir(os.path.join(outputs_directory, subdir))]
107
+
108
+ # Use the first (or only) subdirectory, or None if there are no subdirectories
109
+ first_subdirectory = subdirectories[0] if subdirectories else None
110
+
111
+ if first_subdirectory:
112
+ # Construct the paths to the video and image files inside the first subdirectory
113
+ subdirectory_path = os.path.join(outputs_directory, first_subdirectory)
114
+ temp_dicom_dir_path = os.path.join(subdirectory_path, "temp_dicom_dir")
115
+
116
+ # Get a list of subdirectories inside the 'temp_dicom_dir' directory
117
+ dicom_subdirectories = [subdir for subdir in os.listdir(temp_dicom_dir_path)
118
+ if os.path.isdir(os.path.join(temp_dicom_dir_path, subdir))]
119
+
120
+ # Use the first (or only) subdirectory inside 'temp_dicom_dir', or None if there are none
121
+ first_dicom_subdirectory = dicom_subdirectories[0] if dicom_subdirectories else None
122
+
123
+ if first_dicom_subdirectory:
124
+ video_path = os.path.join(temp_dicom_dir_path, first_dicom_subdirectory, "images/summary/aaa.mp4")
125
+ image_path = os.path.join(temp_dicom_dir_path, first_dicom_subdirectory, "images/summary/diameter_graph.png")
126
+ largest_slice = os.path.join(temp_dicom_dir_path, first_dicom_subdirectory, "images/summary/out.png")
127
+
128
+ if os.path.exists(largest_slice):
129
+ st.title("Largest Slice")
130
+ st.image(largest_slice, use_column_width=True)
131
+
132
+ # Display the video generated by the inference script
133
+ if os.path.exists(video_path):
134
+ st.title("Video")
135
+ st.video(video_path, format="video/mp4")
136
+
137
+ # Display the image generated by the inference script
138
+ if os.path.exists(image_path):
139
+ st.title("Diameter Graph")
140
+ st.image(image_path, use_column_width=True)
141
+ else:
142
+ st.warning("No subdirectories or folders found inside 'temp_dicom_dir'.")
143
+ else:
144
+ st.warning("No subdirectories or folders found inside the 'outputs' directory.")