andreped commited on
Commit
ff7eaad
2 Parent(s): 3e715d7 1b4af4d

Merge pull request #17 from andreped/demo-hf

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. README.md +2 -2
  3. demo/src/gui.py +5 -4
  4. demo/src/inference.py +14 -8
Dockerfile CHANGED
@@ -65,4 +65,4 @@ RUN rm -r *.zip
65
  RUN wget "https://github.com/andreped/neukit/releases/download/test-data/test_thorax_CT.nii.gz"
66
 
67
  # CMD ["/bin/bash"]
68
- CMD ["python3", "app.py"]
 
65
  RUN wget "https://github.com/andreped/neukit/releases/download/test-data/test_thorax_CT.nii.gz"
66
 
67
  # CMD ["/bin/bash"]
68
+ CMD ["python3", "demo/app.py"]
README.md CHANGED
@@ -7,7 +7,7 @@ app_port: 7860
7
  emoji: 🧠
8
  pinned: false
9
  license: mit
10
- app_file: app.py
11
  ---
12
 
13
  <div align="center">
@@ -58,7 +58,7 @@ virtualenv -python3 venv --clear
58
  source venv/bin/activate
59
  pip install -r ./demo/requirements.txt
60
 
61
- python app.py --cwd ./
62
  ```
63
 
64
  ## [Troubleshooting](https://github.com/raidionics/AeroPath#troubleshooting)
 
7
  emoji: 🧠
8
  pinned: false
9
  license: mit
10
+ app_file: demo/app.py
11
  ---
12
 
13
  <div align="center">
 
58
  source venv/bin/activate
59
  pip install -r ./demo/requirements.txt
60
 
61
+ python demo/app.py --cwd ./
62
  ```
63
 
64
  ## [Troubleshooting](https://github.com/raidionics/AeroPath#troubleshooting)
demo/src/gui.py CHANGED
@@ -20,7 +20,7 @@ class WebUI:
20
  self.pred_images = []
21
 
22
  # @TODO: This should be dynamically set based on chosen volume size
23
- self.nb_slider_items = 300
24
 
25
  self.model_name = model_name
26
  self.cwd = cwd
@@ -29,10 +29,12 @@ class WebUI:
29
  self.class_name = "airways" # default
30
  self.class_names = {
31
  "airways": "CT_Airways",
 
32
  }
33
 
34
  self.result_names = {
35
- "airways": "Airway",
 
36
  }
37
 
38
  # define widgets not to be rendered immediantly, but later on
@@ -104,8 +106,7 @@ class WebUI:
104
  model_selector = gr.Dropdown(
105
  list(self.class_names.keys()),
106
  label="Task",
107
- info="Which task to perform - one model for"
108
- "each brain tumor type and brain extraction",
109
  multiselect=False,
110
  size="sm",
111
  )
 
20
  self.pred_images = []
21
 
22
  # @TODO: This should be dynamically set based on chosen volume size
23
+ self.nb_slider_items = 415
24
 
25
  self.model_name = model_name
26
  self.cwd = cwd
 
29
  self.class_name = "airways" # default
30
  self.class_names = {
31
  "airways": "CT_Airways",
32
+ "lungs": "CT_Lungs",
33
  }
34
 
35
  self.result_names = {
36
+ "airways": "Airways",
37
+ "lungs": "Lungs",
38
  }
39
 
40
  # define widgets not to be rendered immediantly, but later on
 
106
  model_selector = gr.Dropdown(
107
  list(self.class_names.keys()),
108
  label="Task",
109
+ info="Which task to perform",
 
110
  multiselect=False,
111
  size="sm",
112
  )
demo/src/inference.py CHANGED
@@ -2,6 +2,7 @@ import configparser
2
  import logging
3
  import os
4
  import shutil
 
5
 
6
 
7
  def run_model(
@@ -29,6 +30,8 @@ def run_model(
29
  if os.path.exists("./result/"):
30
  shutil.rmtree("./result/")
31
 
 
 
32
  try:
33
  # setup temporary patient directory
34
  filename = input_path.split("/")[-1]
@@ -86,12 +89,15 @@ def run_model(
86
  + ".nii.gz",
87
  "./prediction.nii.gz",
88
  )
89
-
 
 
 
 
90
  except Exception as e:
91
- print(e)
92
-
93
- # Clean-up
94
- if os.path.exists(patient_directory):
95
- shutil.rmtree(patient_directory)
96
- if os.path.exists(output_path):
97
- shutil.rmtree(output_path)
 
2
  import logging
3
  import os
4
  import shutil
5
+ import traceback
6
 
7
 
8
  def run_model(
 
30
  if os.path.exists("./result/"):
31
  shutil.rmtree("./result/")
32
 
33
+ patient_directory = ''
34
+ output_path = ''
35
  try:
36
  # setup temporary patient directory
37
  filename = input_path.split("/")[-1]
 
89
  + ".nii.gz",
90
  "./prediction.nii.gz",
91
  )
92
+ # Clean-up
93
+ if os.path.exists(patient_directory):
94
+ shutil.rmtree(patient_directory)
95
+ if os.path.exists(output_path):
96
+ shutil.rmtree(output_path)
97
  except Exception as e:
98
+ print(traceback.format_exc())
99
+ # Clean-up
100
+ if os.path.exists(patient_directory):
101
+ shutil.rmtree(patient_directory)
102
+ if os.path.exists(output_path):
103
+ shutil.rmtree(output_path)