segmentation_models icon indicating copy to clipboard operation
segmentation_models copied to clipboard

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

Open csemtech opened this issue 3 years ago • 1 comments

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

csemtech avatar Nov 22 '21 08:11 csemtech

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)

Parisa-Asadi avatar Jan 06 '22 18:01 Parisa-Asadi