deepakri201 commited on
Commit
b7cebe5
·
1 Parent(s): 6760701

adding button to run inference

Browse files
Files changed (1) hide show
  1. app.py +22 -49
app.py CHANGED
@@ -54,56 +54,29 @@ selected_series = st.selectbox("Select Series", series)
54
 
55
  print('selected_series: ' + str(selected_series))
56
 
 
 
57
 
58
- # # Button to process IDC data
59
- # if st.button("Process IDC data"):
60
- # # Fetch data from IDC based on selection
61
- # selection = index_df[
62
- # (index_df["SeriesInstanceUID"] == selected_series)
63
- # ]
64
-
65
- # series_instance_uids = selection["SeriesInstanceUID"].tolist()
66
-
67
- # # with TemporaryDirectory() as temp_dir:
68
- # download_errors = []
69
- # #input_dir = os.path.join(temp_dir, "input_data")
70
- # input_dir=Path("input_data/")
71
- # if input_dir.exists():
72
- # shutil.rmtree(input_dir)
73
- # os.makedirs(input_dir, exist_ok=True)
74
-
75
- # try:
76
- # client.download_from_selection(seriesInstanceUID=series_instance_uids, downloadDir=input_dir)
77
- # except Exception as e:
78
- # download_errors.append(f"Error downloading data: {str(e)}")
79
-
80
- # if download_errors:
81
- # st.error("\n".join(download_errors))
82
- # else:
83
- # st.success("Data downloaded successfully.")
84
-
85
- # # Process downloaded DICOM data
86
- # dicom_files = [str(file) for file in input_dir.glob('**/*.dcm')]
87
- # # parquet_file = 'dcm2parquet_output.parquet'
88
- # # save_dicom_header_to_parquet(dicom_files, parquet_file)
89
-
90
- if os.path.exists("DICOMScanClassification_user_demo.ipynb"):
91
- os.remove("DICOMScanClassification_user_demo.ipynb")
92
-
93
- subprocess.run(["wget", "https://raw.githubusercontent.com/deepakri201/DICOMScanClassification_pw41/main/DICOMScanClassification_user_demo.ipynb"])
94
-
95
- pm.execute_notebook(
96
- "DICOMScanClassification_user_demo.ipynb",
97
- 'output.ipynb',
98
- parameters = dict(SeriesInstanceUID=selected_series)
99
- )
100
-
101
- with open('output.ipynb', "rb") as f:
102
- st.download_button(
103
- label="Download the output notebook file",
104
- data=f,
105
- file_name="output.ipynb",
106
- mime="application/json"
107
  )
108
 
 
 
 
 
 
 
 
 
109
 
 
54
 
55
  print('selected_series: ' + str(selected_series))
56
 
57
+ # Button to run the notebook - which loads the pretrained models and runs inference
58
+ if st.button("Run inference"):
59
 
60
+ # Code to run when the button is pressed
61
+ st.write("Button pressed! Running inference")
62
+
63
+ if os.path.exists("DICOMScanClassification_user_demo.ipynb"):
64
+ os.remove("DICOMScanClassification_user_demo.ipynb")
65
+
66
+ subprocess.run(["wget", "https://raw.githubusercontent.com/deepakri201/DICOMScanClassification_pw41/main/DICOMScanClassification_user_demo.ipynb"])
67
+
68
+ pm.execute_notebook(
69
+ "DICOMScanClassification_user_demo.ipynb",
70
+ 'output.ipynb',
71
+ parameters = dict(SeriesInstanceUID=selected_series)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  )
73
 
74
+ with open('output.ipynb', "rb") as f:
75
+ st.download_button(
76
+ label="Download the output notebook file",
77
+ data=f,
78
+ file_name="output.ipynb",
79
+ mime="application/json"
80
+ )
81
+
82