osbm commited on
Commit
010252d
1 Parent(s): 3f6023b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -11
main.py CHANGED
@@ -86,17 +86,17 @@ class ProstateSegmentationAlgorithm(SegmentationAlgorithm):
86
 
87
  # input / output paths for algorithm
88
  self.input_dirs = [
89
- "/input/images/transverse-t2-prostate-mri"
90
  ]
91
  self.scan_paths = []
92
- self.prostate_segmentation_path_pz = Path("/output/images/softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz.mha")
93
- self.prostate_segmentation_path_tz = Path("/output/images/softmax-prostate-central-gland-segmentation/prostate_gland_sm_tz.mha")
94
- self.prostate_segmentation_path = Path("/output/images/prostate-zonal-segmentation/prostate_gland.mha")
95
 
96
  # input / output paths for nnUNet
97
- self.nnunet_inp_dir = Path("/opt/algorithm/nnunet/input")
98
- self.nnunet_out_dir = Path("/opt/algorithm/nnunet/output")
99
- self.nnunet_results = Path("/opt/algorithm/results")
100
 
101
  # ensure required folders exist
102
  self.nnunet_inp_dir.mkdir(exist_ok=True, parents=True)
@@ -246,16 +246,24 @@ class ProstateSegmentationAlgorithm(SegmentationAlgorithm):
246
  def predict(input_file):
247
  print("Making prediction")
248
  image = sitk.ReadImage(input_file)
249
- print(image.size)
 
250
  ProstateSegmentationAlgorithm().process()
251
- return input_file
 
 
 
 
 
252
 
253
  print("Starting interface")
254
  demo = gr.Interface(
255
  fn=predict,
256
- inputs=gr.File(file_count="single", file_types=[".mha", ".nii.gz", ".nii"]),
257
  outputs=(
258
- gr.File()
 
 
259
  ),
260
  cache_examples=False,
261
  # outputs=gr.Label(num_top_classes=3),
 
86
 
87
  # input / output paths for algorithm
88
  self.input_dirs = [
89
+ "./input/images/transverse-t2-prostate-mri"
90
  ]
91
  self.scan_paths = []
92
+ self.prostate_segmentation_path_pz = Path("./output/images/softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz.mha")
93
+ self.prostate_segmentation_path_tz = Path("./output/images/softmax-prostate-central-gland-segmentation/prostate_gland_sm_tz.mha")
94
+ self.prostate_segmentation_path = Path("./output/images/prostate-zonal-segmentation/prostate_gland.mha")
95
 
96
  # input / output paths for nnUNet
97
+ self.nnunet_inp_dir = Path("./nnunet/input")
98
+ self.nnunet_out_dir = Path("./nnunet/output")
99
+ self.nnunet_results = Path("./results")
100
 
101
  # ensure required folders exist
102
  self.nnunet_inp_dir.mkdir(exist_ok=True, parents=True)
 
246
  def predict(input_file):
247
  print("Making prediction")
248
  image = sitk.ReadImage(input_file)
249
+ sitk.WriteImage(image, "./input/images/transverse-t2-prostate-mri/1009_2222_t2w.mha")
250
+
251
  ProstateSegmentationAlgorithm().process()
252
+
253
+
254
+ return (
255
+ "./output/images/softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz.mha",
256
+ "./output/images/softmax-prostate-central-gland-segmentation/prostate_gland_sm_tz.mha",
257
+ "./output/images/prostate-zonal-segmentation/prostate_gland.mha"
258
 
259
  print("Starting interface")
260
  demo = gr.Interface(
261
  fn=predict,
262
+ inputs=gr.File(label="input T2 image (3d)", file_count="single", file_types=[".mha", ".nii.gz", ".nii"]),
263
  outputs=(
264
+ gr.File(label="softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz"),
265
+ gr.File(label="softmax-prostate-central-gland-segmentation/prostate_gland_sm_tz"),
266
+ gr.File(label="prostate-zonal-segmentation/prostate_gland"),
267
  ),
268
  cache_examples=False,
269
  # outputs=gr.Label(num_top_classes=3),