soumickmj commited on
Commit
d036cbd
·
1 Parent(s): 1f62d68
Files changed (2) hide show
  1. app.py +18 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -9,6 +9,7 @@ from transformers import AutoModel
9
  import os
10
  import tempfile
11
  from pathlib import Path
 
12
 
13
  # Set page configuration
14
  st.set_page_config(
@@ -33,7 +34,7 @@ with st.sidebar:
33
  st.markdown("© 2024 Soumick Chatterjee | Glastonbury Group | Human Technopole")
34
 
35
  # Main content
36
- st.header("From Single-slice cardiac long-axis dynamic CINE scan (3D: TxHxW) to 128 latent factors...")
37
 
38
  # File uploader
39
  uploaded_file = st.file_uploader(
@@ -121,10 +122,14 @@ if uploaded_file is not None and process_button:
121
  # Convert output to NumPy array
122
  output_np = output.detach().cpu().numpy()
123
  output_list = output_np.flatten().tolist()
 
 
124
  output_data = {
125
  "latent_factors": output_list
126
  }
127
  json_str = json.dumps(output_data, indent=4)
 
 
128
  st.download_button(
129
  label="Download Output as a JSON File",
130
  data=json_str,
@@ -132,6 +137,18 @@ if uploaded_file is not None and process_button:
132
  mime='application/json'
133
  )
134
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  except Exception as e:
136
  st.error(f"An error occurred: {e}")
137
  elif uploaded_file is None:
 
9
  import os
10
  import tempfile
11
  from pathlib import Path
12
+ import pandas as pd
13
 
14
  # Set page configuration
15
  st.set_page_config(
 
34
  st.markdown("© 2024 Soumick Chatterjee | Glastonbury Group | Human Technopole")
35
 
36
  # Main content
37
+ st.header("From single-slice cardiac long-axis dynamic CINE scan (3D: TxHxW) to 128 latent factors...")
38
 
39
  # File uploader
40
  uploaded_file = st.file_uploader(
 
122
  # Convert output to NumPy array
123
  output_np = output.detach().cpu().numpy()
124
  output_list = output_np.flatten().tolist()
125
+
126
+ # Prepare data for JSON
127
  output_data = {
128
  "latent_factors": output_list
129
  }
130
  json_str = json.dumps(output_data, indent=4)
131
+
132
+ # Download button for JSON file
133
  st.download_button(
134
  label="Download Output as a JSON File",
135
  data=json_str,
 
137
  mime='application/json'
138
  )
139
 
140
+ # Prepare data for CSV
141
+ df = pd.DataFrame({'latent_factors': output_list})
142
+ csv_str = df.to_csv(index=False)
143
+
144
+ # Download button for CSV file
145
+ st.download_button(
146
+ label="Download Output as CSV File",
147
+ data=csv_str,
148
+ file_name='latent_factors.csv',
149
+ mime='text/csv'
150
+ )
151
+
152
  except Exception as e:
153
  st.error(f"An error occurred: {e}")
154
  elif uploaded_file is None:
requirements.txt CHANGED
@@ -7,4 +7,5 @@ lpips
7
  torchvision
8
  pyssim
9
  pytorch_fid
10
- scikit-image
 
 
7
  torchvision
8
  pyssim
9
  pytorch_fid
10
+ scikit-image
11
+ pandas