@@ -575,7 +575,7 @@ def run_test():
575
575
# TODO convert it from command line to python code
576
576
# threading.Thread(target=run_command_async, args=(complete_command,)).start()
577
577
578
- test_process = Process (target = run_command_async , args = "test" )
578
+ test_process = Process (target = run_command_async , args = ( "test" , 4 , 2 , 0.01 ) )
579
579
test_process .start ()
580
580
test_process .join ()
581
581
print ("Test process started" )
@@ -598,69 +598,6 @@ def run_test():
598
598
data_json = json .load (f )
599
599
label_num = len (data_json ['labels' ])
600
600
601
- # if os.environ['MODEL_NAME'] == 'nnunet3d':
602
- # if file_ext in ['.gz', '.nrrd', '.mha', '.nii']:
603
- # img = sitk.ReadImage(img_path)
604
- # img = sitk.GetArrayFromImage(img)
605
- #
606
- # pred = sitk.ReadImage(prediction_path)
607
- # pred = sitk.GetArrayFromImage(pred)
608
- # ground_truth = sitk.ReadImage(ground_truth_path)
609
- # ground_truth = sitk.GetArrayFromImage(ground_truth)
610
- # else:
611
- # return jsonify({'status': 'Please use png, bmp, tif, nii.gz, nrrd or mha format.'})
612
- #
613
- # half_layer = int(np.argmax(ground_truth.sum(axis=(1, 2))))
614
- # img = img[half_layer]
615
- # img = np.repeat(img[:, :, np.newaxis], 3, axis=2)
616
- #
617
- # mask_result = np.zeros_like(img)
618
- # img_with_GT = img.copy()
619
- #
620
- # each_metric = []
621
- # for i in range(1, label_num):
622
- # each_metric.append(calculate_metric_percase(pred == i, ground_truth == i))
623
- #
624
- # mask = np.where(pred[half_layer] == i, 1, 0).astype(np.uint8)
625
- # colored_mask = np.zeros_like(img)
626
- # colored_mask[mask == 1] = colors[i - 1]
627
- # img = cv2.addWeighted(img, 1, colored_mask, 0.5, 0)
628
- #
629
- # gt_mask = np.where(ground_truth[half_layer] == i, 1, 0).astype(np.uint8)
630
- # colored_mask_gt = np.zeros_like(img_with_GT)
631
- # colored_mask_gt[gt_mask == 1] = colors[i - 1]
632
- # img_with_GT = cv2.addWeighted(img_with_GT, 1, colored_mask_gt, 0.5, 0)
633
- #
634
- # mask_result[mask == 1] = colors[i - 1]
635
- #
636
- # metric_list.append(each_metric)
637
- #
638
- # img_with_mask_save_path = os.path.join(os.environ['nnUNet_results'], os.environ['MODEL_NAME'],
639
- # os.environ['current_dataset'], nnUNetPlans,
640
- # 'visualization_result', test_img_name + '.png')
641
- # os.makedirs(
642
- # os.path.join(os.environ['nnUNet_results'], os.environ['MODEL_NAME'], os.environ['current_dataset'],
643
- # nnUNetPlans, 'visualization_result'), exist_ok=True)
644
- # cv2.imwrite(img_with_mask_save_path, img)
645
- #
646
- # img_with_GT_save_path = os.path.join(os.environ['nnUNet_results'], os.environ['MODEL_NAME'],
647
- # os.environ['current_dataset'], nnUNetPlans, 'GT_result',
648
- # test_img_name + '.png')
649
- # os.makedirs(
650
- # os.path.join(os.environ['nnUNet_results'], os.environ['MODEL_NAME'], os.environ['current_dataset'],
651
- # nnUNetPlans, 'GT_result'), exist_ok=True)
652
- # cv2.imwrite(img_with_GT_save_path, img_with_GT)
653
- #
654
- # mask_save_path = os.path.join(os.environ['nnUNet_results'], os.environ['MODEL_NAME'],
655
- # os.environ['current_dataset'], nnUNetPlans, 'mask_result',
656
- # test_img_name + '.png')
657
- # os.makedirs(
658
- # os.path.join(os.environ['nnUNet_results'], os.environ['MODEL_NAME'], os.environ['current_dataset'],
659
- # nnUNetPlans, 'mask_result'), exist_ok=True)
660
- # cv2.imwrite(mask_save_path, mask_result)
661
-
662
- # else:
663
-
664
601
if file_ext in ['.png' , '.bmp' , '.tif' ]:
665
602
666
603
img = cv2 .imread (img_path , cv2 .IMREAD_UNCHANGED )
0 commit comments