segmentation_models icon indicating copy to clipboard operation
segmentation_models copied to clipboard

Keras layers to Tensorflow keras layers - help!

Open sachinkmohan opened this issue 2 years ago • 1 comments

Wonderful repository! Thanks!

Using -> TF 1.15

I wanted to optimize this repository using the tensorflow model optimization techniques but I am having a challenge.

After creating the model as below

# define network parameters
n_classes = 1 if len(CLASSES) == 1 else (len(CLASSES) + 1)  # case for binary and multiclass segmentation
activation = 'sigmoid' if n_classes == 1 else 'softmax'

#create model
model = sm.Unet(BACKBONE, classes=n_classes, activation=activation)

I checked the type of the model type(model) -> keras.engine.training.Model

But I need the model type to be -> tensorflow.python.keras.engine.training.Model

Does someone have an idea how to convert into tensorflow.python.keras.engine.training.Model ?

sachinkmohan avatar May 01 '22 14:05 sachinkmohan

Have you tried : import segmentation_models as sm sm.set_framework('tf.keras') ?

kitbransby avatar Jul 20 '22 13:07 kitbransby