Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -72,54 +72,56 @@ if uploaded_zip_file is not None:
|
|
72 |
st.pyplot(plt)
|
73 |
|
74 |
if st.button("Analyze"):
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
command = "./inference.sh"
|
84 |
-
|
85 |
-
try:
|
86 |
-
subprocess.run(command, shell=True, check=True)
|
87 |
-
print("Script 'inference.sh' has started running.")
|
88 |
-
except subprocess.CalledProcessError as e:
|
89 |
-
print(f"Error while making the script executable: {e}")
|
90 |
|
91 |
-
|
92 |
-
subprocess_executed = True
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
if os.path.isdir(os.path.join(outputs_directory, subdir))]
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
|
125 |
|
|
|
72 |
st.pyplot(plt)
|
73 |
|
74 |
if st.button("Analyze"):
|
75 |
+
command = "chmod +x inference.sh"
|
76 |
|
77 |
+
try:
|
78 |
+
subprocess.run(command, shell=True, check=True)
|
79 |
+
print("Script 'inference.sh' has started running.")
|
80 |
+
except subprocess.CalledProcessError as e:
|
81 |
+
print(f"Error while making the script executable: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
command = "./inference.sh"
|
|
|
84 |
|
85 |
+
try:
|
86 |
+
subprocess.run(command, shell=True, check=True)
|
87 |
+
print("Script 'inference.sh' has started running.")
|
88 |
+
except subprocess.CalledProcessError as e:
|
89 |
+
print(f"Error while making the script executable: {e}")
|
|
|
90 |
|
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/outputs"
|
96 |
+
|
97 |
+
# Get a list of subdirectories inside the 'outputs' directory
|
98 |
+
subdirectories = [subdir for subdir in os.listdir(outputs_directory)
|
99 |
+
if os.path.isdir(os.path.join(outputs_directory, subdir))]
|
100 |
+
|
101 |
+
# Use the first (or only) subdirectory, or None if there are no subdirectories
|
102 |
+
first_subdirectory = subdirectories[0] if subdirectories else None
|
103 |
+
|
104 |
+
if first_subdirectory:
|
105 |
+
# Construct the paths to the video and image files inside the first subdirectory
|
106 |
+
video_path = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/aaa.mp4")
|
107 |
+
image_path = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/diameter_graph.png")
|
108 |
+
largest_slice = os.path.join(outputs_directory, first_subdirectory, "temp_dicom_dir/images/summary/out.png")
|
109 |
+
|
110 |
+
if os.path.exists(largest_slice):
|
111 |
+
st.title("Largest Slice")
|
112 |
+
st.image(largest_slice, use_column_width=True)
|
113 |
+
|
114 |
+
# Display the video generated by the inference script
|
115 |
+
if os.path exists(video_path):
|
116 |
+
st.title("Video")
|
117 |
+
st.video(video_path, format="video/mp4")
|
118 |
+
|
119 |
+
# Display the image generated by the inference script
|
120 |
+
if os.path.exists(image_path):
|
121 |
+
st.title("Diameter Graph")
|
122 |
+
st.image(image_path, use_column_width=True)
|
123 |
+
except Exception as e:
|
124 |
+
st.error(f"Error: {str(e)}")
|
125 |
|
126 |
|
127 |
|