Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

eval.py 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  1. import numpy as np
  2. from .const_eval import *
  3. from .functions import *
  4. from .model_architecture import build_model
  5. t1 = [os.path.join(os.getcwd(),'data/raw/HGG/Brats18_2013_10_1/Brats18_2013_10_1_t1.nii.gz')]
  6. t2 = [os.path.join(os.getcwd(),'data/raw/HGG/Brats18_2013_10_1/Brats18_2013_10_1_t2.nii.gz')]
  7. flair = [os.path.join(os.getcwd(),'data/raw/HGG/Brats18_2013_10_1/Brats18_2013_10_1_flair.nii.gz')]
  8. t1ce = [os.path.join(os.getcwd(),'data/raw/HGG/Brats18_2013_10_1/Brats18_2013_10_1_t1ce.nii.gz')]
  9. eval_data: np.array = np.empty((1,) + input_shape, dtype=np.float32)
  10. for index, item in enumerate(zip(t1, t2, flair, t1ce)):
  11. eval_data[index] = np.array(
  12. [process_img(load_Nift2np(modal_path), out_shape=input_shape[1:]) for modal_path in item])
  13. break
  14. model = build_model(input_shape=input_shape, output_channels=output_channels)
  15. model.load_weights(os.path.join(os.getcwd(),'model_weights/model_weights.h5'))
  16. pred = model.predict(eval_data)
  17. base_path = os.path.join(os.getcwd(),'data/eval/')
  18. if not os.path.isdir(base_path):
  19. os.makedirs(base_path)
  20. for index,modal in enumerate(['t1', 't2', 'flair', 't1ce']):
  21. ni_img = nib.Nifti1Image(pred[1][0,index,:,:,:], affine=np.eye(4))
  22. nib.save(ni_img, base_path+f'{modal}.nii.gz')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...