Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -91,17 +91,34 @@ if uploaded_zip_file is not None:
|
|
91 |
# Set the flag to indicate that subprocess commands have been executed
|
92 |
subprocess_executed = True
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
except Exception as e:
|
107 |
st.error(f"Error: {str(e)}")
|
|
|
91 |
# Set the flag to indicate that subprocess commands have been executed
|
92 |
subprocess_executed = True
|
93 |
|
94 |
+
# Assuming the 'outputs' directory is located at "/home/user/app/C2C/comp2comp/outputs"
|
95 |
+
outputs_directory = "/home/user/app/C2C/comp2comp/outputs"
|
96 |
+
|
97 |
+
# Get a list of subdirectories inside the 'outputs' directory
|
98 |
+
subdirectories = [subdir for subdir in os.listdir(outputs_directory) if os.path.isdir(os.path.join(outputs_directory, subdir)]
|
99 |
+
|
100 |
+
if not subdirectories:
|
101 |
+
# If there are no subdirectories, use the only folder inside the 'outputs' directory
|
102 |
+
subdirectories = [d for d in os.listdir(outputs_directory) if os.path.isdir(os.path.join(outputs_directory, d))]
|
103 |
+
|
104 |
+
if subdirectories:
|
105 |
+
# Get the first (or only) subdirectory
|
106 |
+
first_subdirectory = subdirectories[0]
|
107 |
+
|
108 |
+
# Construct the paths to the video and image files inside the first subdirectory
|
109 |
+
video_path = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/aaa.mp4")
|
110 |
+
image_path = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/diameter_graph.png")
|
111 |
+
|
112 |
+
# Display the video generated by the inference script
|
113 |
+
if os.path.exists(video_path):
|
114 |
+
st.video(video_path, format="video/mp4")
|
115 |
+
|
116 |
+
# Display the image generated by the inference script
|
117 |
+
if os.path.exists(image_path):
|
118 |
+
st.image(image_path, caption="Diameter Graph", use_column_width=True)
|
119 |
+
else:
|
120 |
+
st.warning("No subdirectories or folders found inside the 'outputs' directory.")
|
121 |
+
|
122 |
|
123 |
except Exception as e:
|
124 |
st.error(f"Error: {str(e)}")
|