frankkramer-lab / MIScnn

A framework for Medical Image Segmentation with Convolutional Neural Networks and Deep Learning
GNU General Public License v3.0
402 stars 116 forks source link

60 Seconds to a MIS Pipeline #89

Closed lcaronson closed 3 years ago

lcaronson commented 3 years ago

Hello, thank you so much for being such a descriptive and helpful resource!

I am getting an error which stems from line 82 of keras\initializers__init__.py stating AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'.

The block of code is below:

if tf.internal.tf2.enabled():

For V2, entries are generated automatically based on the content of

# initializers_v2.py.
v2_objs = {}
base_cls = initializers_v2.Initializer
generic_utils.populate_dict_with_module_objects(     <---------------------------- (line throwing error)
    v2_objs,
    [initializers_v2],
    obj_filter=lambda x: inspect.isclass(x) and issubclass(x, base_cls))
for key, value in v2_objs.items():
  LOCAL.ALL_OBJECTS[key] = value
  # Functional aliases.
  LOCAL.ALL_OBJECTS[generic_utils.to_snake_case(key)] = value

else: .......

Any advice would be greatly appreciated!

muellerdo commented 3 years ago

Hello @lcaronson,

mhm, this sounds like it isn't MIScnn related, but about some Tensorflow issues.

Check out this: https://github.com/tensorflow/tensorflow/issues/38012 https://stackoverflow.com/questions/61137954/attributeerror-module-tensorflow-python-keras-utils-generic-utils-has-no-attr

Looks like there is some issue with the newest Tensorflow 2.5.0.

leqnam suggests:

I have the same issue since tried the NMT which is required ft_nightly, so it mays conflict with tf. First uninstall tf_nightly and then force reinstall tf.

pip uninstall tf-nightly
pip install tensorflow --upgrade --force-reinstall

nvs-abhilash suggests:

It worked for me after uninstalling the tf-nightly packages.

pip list | grep tf

Then reinstall tensorflow

pip install tensorflow --upgrade --force-reinstall

and a more 'hacky' approach was suggested by danial880:

Please copy "populate_dict_with_module_objects" function from this link (line 827 to 832) and add it to "generic_utils.py"

Have a try on these approaches.

Cheers, Dominik

Marmar202 commented 3 years ago

I'm getting this error as well, my tensorflow is 2.5.0

AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'

lcaronson commented 3 years ago

@muellerdo Thank you for the suggestions, the third one you mentioned seemed to work for me.

@Marmar202 I used the danial880 approach, and it seemed to solve the issue.

lcaronson commented 3 years ago

@muellerdo I seem to be running across more issues similar to this one (likely because I am using Python 3.9 with Tensorflow 2.5.0). Would it be better to use Python 3.6 and Tensorflow 2.2.0, as mentioned in your paper?