qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.67k stars 1.03k forks source link

AttributeError: module 'keras.utils' has no attribute 'get_file' #503

Open csemtech opened 2 years ago

csemtech commented 2 years ago

new import efficientnet.keras as efn import keras.backend as backend

with strategy.scope(): def build_model(): eff0 = efn.EfficientNetB0(weights='imagenet',include_top=False,input_shape=(224,224,3)) X = GlobalAveragePooling2D()(eff0.output) X = Dropout(0.5)(X) X = Dense(64)(X) X = Activation('relu')(X) X = Dense(7)(X) X = Activation('softmax')(X)

  model = Model(inputs = eff0.input, outputs = X)
  opt = Adam(lr=1.5e-4)
  model.compile(loss='categorical_crossentropy',
              optimizer=opt, 
              metrics=['accuracy'])
  return model

model = build_model() model.summary()

Error occur in bold line

error

Parisa-Asadi commented 2 years ago

use this: %env SM_FRAMEWORK=tf.keras before you run the model. it worked for me. or you can use this: import os os.environ['SM_FRAMEWORK'] = 'tf.keras' from segmentation_models import Unet #(for example)