osbm commited on
Commit
dccc77b
1 Parent(s): 1a5ed5f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +15 -5
main.py CHANGED
@@ -252,19 +252,24 @@ class csPCaAlgorithm(SegmentationAlgorithm):
252
  print(subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=True).stdout)
253
 
254
 
255
- def predict(input_file):
256
  print("Making prediction")
257
- image = sitk.ReadImage(input_file)
 
 
258
 
259
  os.makedirs("./input/images/transverse-t2-prostate-mri/", exist_ok=True)
 
 
260
  os.makedirs("./output/images/softmax-prostate-peripheral-zone-segmentation", exist_ok=True)
261
  os.makedirs("./output/images/softmax-prostate-central-gland-segmentation", exist_ok=True)
262
  os.makedirs("./output/images/prostate-zonal-segmentation", exist_ok=True)
263
 
264
- sitk.WriteImage(image, "./input/images/transverse-t2-prostate-mri/1009_2222_t2w.mha")
 
 
265
 
266
  csPCaAlgorithm().process()
267
-
268
 
269
  return (
270
  "./output/images/softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz.mha",
@@ -278,7 +283,12 @@ demo = gr.Interface(
278
  description="description text",
279
  article="article text",
280
  fn=predict,
281
- inputs=gr.File(label="input T2 image (3d)", file_count="single", file_types=[".mha", ".nii.gz", ".nii"]),
 
 
 
 
 
282
  outputs=[
283
  gr.File(label="softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz"),
284
  gr.File(label="softmax-prostate-central-gland-segmentation/prostate_gland_sm_tz"),
 
252
  print(subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=True).stdout)
253
 
254
 
255
+ def predict(t2_file, adc_file, hbv_file):
256
  print("Making prediction")
257
+ t2_file = sitk.ReadImage(t2_file)
258
+ adc_file = sitk.ReadImage(adc_file)
259
+ hbv_file = sitk.ReadImage(hbv_file)
260
 
261
  os.makedirs("./input/images/transverse-t2-prostate-mri/", exist_ok=True)
262
+ os.makedirs("./input/images/transverse-adc-prostate-mri/", exist_ok=True)
263
+ os.makedirs("./input/images/transverse-hbv-prostate-mri/", exist_ok=True)
264
  os.makedirs("./output/images/softmax-prostate-peripheral-zone-segmentation", exist_ok=True)
265
  os.makedirs("./output/images/softmax-prostate-central-gland-segmentation", exist_ok=True)
266
  os.makedirs("./output/images/prostate-zonal-segmentation", exist_ok=True)
267
 
268
+ sitk.WriteImage(t2_file, "./input/images/transverse-t2-prostate-mri/1009_2222_t2w.mha")
269
+ sitk.WriteImage(adc_file, "./input/images/transverse-t2-prostate-mri/1009_2222_adc.mha")
270
+ sitk.WriteImage(hbv_file, "./input/images/transverse-t2-prostate-mri/1009_2222_hbv.mha")
271
 
272
  csPCaAlgorithm().process()
 
273
 
274
  return (
275
  "./output/images/softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz.mha",
 
283
  description="description text",
284
  article="article text",
285
  fn=predict,
286
+ inputs=[
287
+ gr.File(label="input T2 image (3d)", file_count="single", file_types=[".mha", ".nii.gz", ".nii"]),
288
+ gr.File(label="input ADC image (3d)", file_count="single", file_types=[".mha", ".nii.gz", ".nii"]),
289
+ gr.File(label="input HBV image (3d)", file_count="single", file_types=[".mha", ".nii.gz", ".nii"]),
290
+ ],
291
+
292
  outputs=[
293
  gr.File(label="softmax-prostate-peripheral-zone-segmentation/prostate_gland_sm_pz"),
294
  gr.File(label="softmax-prostate-central-gland-segmentation/prostate_gland_sm_tz"),