Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,6 +34,22 @@ def install_dependencies():
|
|
| 34 |
except subprocess.CalledProcessError as e:
|
| 35 |
print(f"Error while running the script: {e}")
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Function to read and display the DICOM image
|
| 38 |
@st.cache_resource
|
| 39 |
def display_dicom_image(selected_slice, dicom_files):
|
|
@@ -78,24 +94,7 @@ if uploaded_zip_file is not None:
|
|
| 78 |
st.error(f"Error: {str(e)}")
|
| 79 |
|
| 80 |
if st.button("Analyze"):
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
try:
|
| 84 |
-
subprocess.run(command, shell=True, check=True)
|
| 85 |
-
print("Script 'inference.sh' has started running.")
|
| 86 |
-
except subprocess.CalledProcessError as e:
|
| 87 |
-
print(f"Error while making the script executable: {e}")
|
| 88 |
-
|
| 89 |
-
command = "./inference.sh"
|
| 90 |
-
|
| 91 |
-
try:
|
| 92 |
-
subprocess.run(command, shell=True, check=True)
|
| 93 |
-
print("Script 'inference.sh' has started running.")
|
| 94 |
-
except subprocess.CalledProcessError as e:
|
| 95 |
-
print(f"Error while making the script executable: {e}")
|
| 96 |
-
|
| 97 |
-
# Set the flag to indicate that subprocess commands have been executed
|
| 98 |
-
subprocess_executed = True
|
| 99 |
|
| 100 |
# Assuming the 'outputs' directory is located at "/home/user/app/C2C/comp2comp/outputs"
|
| 101 |
outputs_directory = "/home/user/app/C2C/outputs"
|
|
@@ -127,8 +126,4 @@ if st.button("Analyze"):
|
|
| 127 |
st.title("Diameter Graph")
|
| 128 |
st.image(image_path, use_column_width=True)
|
| 129 |
else:
|
| 130 |
-
st.warning("No subdirectories or folders found inside the 'outputs' directory.")
|
| 131 |
-
|
| 132 |
-
# finally:
|
| 133 |
-
# shutil.rmtree(temp_dir)
|
| 134 |
-
|
|
|
|
| 34 |
except subprocess.CalledProcessError as e:
|
| 35 |
print(f"Error while running the script: {e}")
|
| 36 |
|
| 37 |
+
@st.cache_resource
|
| 38 |
+
def run_inference():
|
| 39 |
+
command = "chmod +x inference.sh"
|
| 40 |
+
try:
|
| 41 |
+
subprocess.run(command, shell=True, check=True)
|
| 42 |
+
print("Script 'inference.sh' has been made executable.")
|
| 43 |
+
except subprocess.CalledProcessError as e:
|
| 44 |
+
print(f"Error while making the script executable: {e}")
|
| 45 |
+
|
| 46 |
+
command = "./inference.sh"
|
| 47 |
+
try:
|
| 48 |
+
subprocess.run(command, shell=True, check=True)
|
| 49 |
+
print("Script 'inference.sh' has started running.")
|
| 50 |
+
except subprocess.CalledProcessError as e:
|
| 51 |
+
print(f"Error while running the script: {e}")
|
| 52 |
+
|
| 53 |
# Function to read and display the DICOM image
|
| 54 |
@st.cache_resource
|
| 55 |
def display_dicom_image(selected_slice, dicom_files):
|
|
|
|
| 94 |
st.error(f"Error: {str(e)}")
|
| 95 |
|
| 96 |
if st.button("Analyze"):
|
| 97 |
+
run_inference()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
# Assuming the 'outputs' directory is located at "/home/user/app/C2C/comp2comp/outputs"
|
| 100 |
outputs_directory = "/home/user/app/C2C/outputs"
|
|
|
|
| 126 |
st.title("Diameter Graph")
|
| 127 |
st.image(image_path, use_column_width=True)
|
| 128 |
else:
|
| 129 |
+
st.warning("No subdirectories or folders found inside the 'outputs' directory.")
|
|
|
|
|
|
|
|
|
|
|
|