module 'keras.utils' has no attribute 'get_file'
model = efn.EfficientNetB0(input_shape=(64, 64, 64, 3), weights='imagenet') in this line
I had the same issue. solved by using import efficientnet_3D.tfkeras as efn instead of import efficientnet_3D.keras as efn
Thanks its working now.
On Sun, Aug 15, 2021, 1:04 PM Amokrane Mancer @.***> wrote:
I had the same issue. solved by using import efficientnet_3D.tfkeras as efn instead of import efficientnet_3D.keras as efn
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ZFTurbo/efficientnet_3D/issues/6#issuecomment-899019488, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKEH4EPOPYFVNB2H6QWDMBTT457I7ANCNFSM5CDSN5MQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
An easy patch I did in __init__.py file, change the function inject_keras_modules importing directly from Tensorlfow instead of Keras because get_file is a function that only exist in tensorflow.keras not in keras.
You must change: import keras for import tensorflow.keras as keras. The new function will be:
def inject_keras_modules(func):
import tensorflow.keras as keras
@functools.wraps(func)
def wrapper(*args, **kwargs):
kwargs['backend'] = keras.backend
kwargs['layers'] = keras.layers
kwargs['models'] = keras.models
kwargs['utils'] = keras.utils
return func(*args, **kwargs)
return wrapper
As I said at the beggining of this comment, this is just a patch
Friends I have another issue, base_model = efn.EfficientNetB0(input_shape=(182,218,182,1), weights='imagenet',classes=2) showing error [ its working only for 3 number of channels]
Downloading data from https://github.com/ZFTurbo/efficientnet_3D/releases/download/v1.0.0/efficientnet-b0_inp_channel_3_tch_0_top_False.h5 19546112/19540520 [==============================] - 0s 0us/step 19554304/19540520 [==============================] - 0s 0us/step
ValueError Traceback (most recent call last)
7 frames <array_function internals> in transpose(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 56 57 try: ---> 58 return bound(*args, **kwds) 59 except TypeError: 60 # A TypeError occurs if the object does have such a method in its
ValueError: axes don't match array
That's right, because pretrained model has 3 channels, and your model has 1 channel. You can't use these weights with your model.
I suggest to close this issue since it have been solved.