Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,6 @@ def run_inference():
|
|
36 |
command = "./inference.sh"
|
37 |
subprocess.run(command, shell=True, check=True)
|
38 |
|
39 |
-
# Function to zip and download files
|
40 |
def zip_and_download(directory, zip_filename):
|
41 |
zipf = zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED)
|
42 |
for root, _, files in os.walk(directory):
|
@@ -48,7 +47,6 @@ def zip_and_download(directory, zip_filename):
|
|
48 |
bytes_data = f.read()
|
49 |
st.download_button(label="Download Outputs", data=bytes_data, file_name=zip_filename, mime="application/zip")
|
50 |
|
51 |
-
# Function to search for files in all subdirectories
|
52 |
def search_file(start_path, target_file):
|
53 |
for root, _, files in os.walk(start_path):
|
54 |
if target_file in files:
|
@@ -92,10 +90,6 @@ def main():
|
|
92 |
image_path = search_file(temp_dicom_dir_path, "diameter_graph.png")
|
93 |
largest_slice = search_file(temp_dicom_dir_path, "out.png")
|
94 |
|
95 |
-
st.write(f"Video Path: {video_path}")
|
96 |
-
st.write(f"Image Path: {image_path}")
|
97 |
-
st.write(f"Largest Slice Path: {largest_slice}")
|
98 |
-
|
99 |
if video_path and image_path and largest_slice:
|
100 |
zip_filename = os.path.join(temp_dir, "outputs.zip")
|
101 |
zip_and_download(temp_dicom_dir_path, zip_filename)
|
@@ -109,11 +103,11 @@ def main():
|
|
109 |
st.title("Diameter Graph")
|
110 |
st.image(image_path, use_column_width=True)
|
111 |
else:
|
112 |
-
st.error("Output files not found
|
113 |
else:
|
114 |
-
st.warning("
|
115 |
else:
|
116 |
-
st.error("
|
117 |
except Exception as e:
|
118 |
st.error(f"Error: {str(e)}")
|
119 |
|
|
|
36 |
command = "./inference.sh"
|
37 |
subprocess.run(command, shell=True, check=True)
|
38 |
|
|
|
39 |
def zip_and_download(directory, zip_filename):
|
40 |
zipf = zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED)
|
41 |
for root, _, files in os.walk(directory):
|
|
|
47 |
bytes_data = f.read()
|
48 |
st.download_button(label="Download Outputs", data=bytes_data, file_name=zip_filename, mime="application/zip")
|
49 |
|
|
|
50 |
def search_file(start_path, target_file):
|
51 |
for root, _, files in os.walk(start_path):
|
52 |
if target_file in files:
|
|
|
90 |
image_path = search_file(temp_dicom_dir_path, "diameter_graph.png")
|
91 |
largest_slice = search_file(temp_dicom_dir_path, "out.png")
|
92 |
|
|
|
|
|
|
|
|
|
93 |
if video_path and image_path and largest_slice:
|
94 |
zip_filename = os.path.join(temp_dir, "outputs.zip")
|
95 |
zip_and_download(temp_dicom_dir_path, zip_filename)
|
|
|
103 |
st.title("Diameter Graph")
|
104 |
st.image(image_path, use_column_width=True)
|
105 |
else:
|
106 |
+
st.error("Output files not found")
|
107 |
else:
|
108 |
+
st.warning("Ouput files not found")
|
109 |
else:
|
110 |
+
st.error("Output files not found")
|
111 |
except Exception as e:
|
112 |
st.error(f"Error: {str(e)}")
|
113 |
|