0

I am trying to use the library Deepbrain to extract brains from the entire MRIs scan I am using the code

def Reduce_Brain(img):
     img_data = img.get_fdata()
     prob = ext.run(img)
     print(prob)

img = nib.load('ADNI_002_S_0295.nii')
Reduce_Brain(img)

however, when I tried this I got the error module 'tensorflow' has no attribute 'Session' which I found was an error to do with the wrong version of tensorflow so I then changed the library code as said in the other question (see below). but this produced more errors such as module 'tensorflow' has no attribute 'gfile'

Tensorflow 2.0 - AttributeError: module 'tensorflow' has no attribute 'Session'

https://github.com/iitzco/deepbrain

Sam Crerar
  • 13
  • 4

1 Answers1

0

In TF 2.x you should use tf.compat.v1.Session() instead of tf.Session(). Take a look at Migrate_tf2 guide for more information

To get TF 1.x like behaviour in TF 2.0 add below code

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()