Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,44 +34,8 @@ if uploaded_zip_file is not None:
|
|
34 |
|
35 |
st.write(f"Temporary directory path: {temp_dir}")
|
36 |
|
37 |
-
# if not subprocess_executed:
|
38 |
-
# # Execute the subprocess commands only once
|
39 |
-
# command = "chmod +x install.sh"
|
40 |
-
# try:
|
41 |
-
# subprocess.run(command, shell=True, check=True)
|
42 |
-
# print("Script 'install.sh' has been made executable.")
|
43 |
-
# except subprocess.CalledProcessError as e:
|
44 |
-
# print(f"Error while making the script executable: {e}")
|
45 |
-
|
46 |
-
# command = "./install.sh"
|
47 |
-
# try:
|
48 |
-
# subprocess.run(command, shell=True, check=True)
|
49 |
-
# print("Script 'install.sh' has started running.")
|
50 |
-
# except subprocess.CalledProcessError as e:
|
51 |
-
# print(f"Error while running the script: {e}")
|
52 |
-
|
53 |
-
|
54 |
-
# command = "chmod +x inference.sh"
|
55 |
-
|
56 |
-
# try:
|
57 |
-
# subprocess.run(command, shell=True, check=True)
|
58 |
-
# print("Script 'inference.sh' has started running.")
|
59 |
-
# except subprocess.CalledProcessError as e:
|
60 |
-
# print(f"Error while making the script executable: {e}")
|
61 |
-
|
62 |
-
# command = "./inference.sh"
|
63 |
-
|
64 |
-
# try:
|
65 |
-
# subprocess.run(command, shell=True, check=True)
|
66 |
-
# print("Script 'inference.sh' has started running.")
|
67 |
-
# except subprocess.CalledProcessError as e:
|
68 |
-
# print(f"Error while making the script executable: {e}")
|
69 |
-
|
70 |
-
# # Set the flag to indicate that subprocess commands have been executed
|
71 |
-
# subprocess_executed = True
|
72 |
-
|
73 |
with zipfile.ZipFile(uploaded_zip_file, "r") as zip_ref:
|
74 |
-
|
75 |
|
76 |
# Get a list of DICOM files in the directory
|
77 |
dicom_files = [os.path.join(temp_dir, f) for f in os.listdir(temp_dir) if f.endswith(".dcm")]
|
@@ -87,6 +51,42 @@ if uploaded_zip_file is not None:
|
|
87 |
plt = display_dicom_image(selected_slice, dicom_files)
|
88 |
st.pyplot(plt)
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
except Exception as e:
|
91 |
st.error(f"Error: {str(e)}")
|
92 |
finally:
|
|
|
34 |
|
35 |
st.write(f"Temporary directory path: {temp_dir}")
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
with zipfile.ZipFile(uploaded_zip_file, "r") as zip_ref:
|
38 |
+
zip_ref.extractall(temp_dir)
|
39 |
|
40 |
# Get a list of DICOM files in the directory
|
41 |
dicom_files = [os.path.join(temp_dir, f) for f in os.listdir(temp_dir) if f.endswith(".dcm")]
|
|
|
51 |
plt = display_dicom_image(selected_slice, dicom_files)
|
52 |
st.pyplot(plt)
|
53 |
|
54 |
+
if not subprocess_executed:
|
55 |
+
# Execute the subprocess commands only once
|
56 |
+
command = "chmod +x install.sh"
|
57 |
+
try:
|
58 |
+
subprocess.run(command, shell=True, check=True)
|
59 |
+
print("Script 'install.sh' has been made executable.")
|
60 |
+
except subprocess.CalledProcessError as e:
|
61 |
+
print(f"Error while making the script executable: {e}")
|
62 |
+
|
63 |
+
command = "./install.sh"
|
64 |
+
try:
|
65 |
+
subprocess.run(command, shell=True, check=True)
|
66 |
+
print("Script 'install.sh' has started running.")
|
67 |
+
except subprocess.CalledProcessError as e:
|
68 |
+
print(f"Error while running the script: {e}")
|
69 |
+
|
70 |
+
|
71 |
+
command = "chmod +x inference.sh"
|
72 |
+
|
73 |
+
try:
|
74 |
+
subprocess.run(command, shell=True, check=True)
|
75 |
+
print("Script 'inference.sh' has started running.")
|
76 |
+
except subprocess.CalledProcessError as e:
|
77 |
+
print(f"Error while making the script executable: {e}")
|
78 |
+
|
79 |
+
command = "./inference.sh"
|
80 |
+
|
81 |
+
try:
|
82 |
+
subprocess.run(command, shell=True, check=True)
|
83 |
+
print("Script 'inference.sh' has started running.")
|
84 |
+
except subprocess.CalledProcessError as e:
|
85 |
+
print(f"Error while making the script executable: {e}")
|
86 |
+
|
87 |
+
# Set the flag to indicate that subprocess commands have been executed
|
88 |
+
subprocess_executed = True
|
89 |
+
|
90 |
except Exception as e:
|
91 |
st.error(f"Error: {str(e)}")
|
92 |
finally:
|