Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,29 +29,6 @@ def display_dicom_image(selected_slice, dicom_files):
|
|
29 |
plt.tight_layout()
|
30 |
return plt
|
31 |
|
32 |
-
def execute_command_with_progress(command, description):
|
33 |
-
st.write(description)
|
34 |
-
process = subprocess.Popen(
|
35 |
-
command,
|
36 |
-
shell=True,
|
37 |
-
stdout=subprocess.PIPE,
|
38 |
-
stderr=subprocess.STDOUT,
|
39 |
-
universal_newlines=True,
|
40 |
-
bufsize=1,
|
41 |
-
)
|
42 |
-
|
43 |
-
for line in process.stdout:
|
44 |
-
st.text(line) # Display the output
|
45 |
-
# Assuming that the script provides a numeric progress value
|
46 |
-
try:
|
47 |
-
progress = float(line.strip()) # Extract a numeric progress value
|
48 |
-
st.progress(progress)
|
49 |
-
except ValueError:
|
50 |
-
pass
|
51 |
-
|
52 |
-
process.wait()
|
53 |
-
st.write(f"{description} has finished.")
|
54 |
-
|
55 |
if uploaded_zip_file is not None:
|
56 |
try:
|
57 |
# Create a temporary directory to unzip the files
|
@@ -95,19 +72,6 @@ if st.button("Analyze"):
|
|
95 |
print("Script 'install.sh' has started running.")
|
96 |
except subprocess.CalledProcessError as e:
|
97 |
print(f"Error while running the script: {e}")
|
98 |
-
|
99 |
-
temp_dir = "/home/user/app/C2C/temp_dicom_dir"
|
100 |
-
|
101 |
-
os.makedirs(temp_dir, exist_ok=True)
|
102 |
-
full_path = os.path.abspath(temp_dir)
|
103 |
-
|
104 |
-
try:
|
105 |
-
execute_command_with_progress(command, "Installing required C2C packages")
|
106 |
-
except subprocess.CalledProcessError as e:
|
107 |
-
st.error(f"Error while making the script executable: {e}")
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
|
112 |
command = "chmod +x inference.sh"
|
113 |
|
|
|
29 |
plt.tight_layout()
|
30 |
return plt
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
if uploaded_zip_file is not None:
|
33 |
try:
|
34 |
# Create a temporary directory to unzip the files
|
|
|
72 |
print("Script 'install.sh' has started running.")
|
73 |
except subprocess.CalledProcessError as e:
|
74 |
print(f"Error while running the script: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
command = "chmod +x inference.sh"
|
77 |
|