mberkay0 / clothing-segmentation

Clothing segmentation with DeepLabV3+
MIT License
50 stars 10 forks source link

NameError: name 'callbacks' is not defined #2

Open Jonovono opened 1 year ago

Jonovono commented 1 year ago

Pretty noob to ML, trying to get this project to run and getting this error. Can you help me out?


NameError Traceback (most recent call last)

in () 4 validation_steps=len(val_gen), 5 epochs=num_epoch, ----> 6 callbacks=callbacks, 7 verbose = 1) NameError: name 'callbacks' is not defined
mberkay0 commented 1 year ago

Greetings @Jonovono, You could define callbacks before starting the model training. Below, I provide an example of a callback. Please set it before training the model.

for more information: callbacks


import tensorflow as tf
from keras.callbacks import ModelCheckpoint

callback_checkpoint = ModelCheckpoint(
    model_filename, 
    verbose=1, 
    monitor='loss', 
    save_weights_only=True,
    save_best_only=True,
    mode='min'
)

callbacks = [
    callback_checkpoint,
    tf.keras.callbacks.ReduceLROnPlateau(),
]
Jonovono commented 1 year ago

Thanks @mberkay0 , I think that helped but then get onto this error:

RuntimeError: You must compile your model before training/testing. Use model.compile(optimizer, loss).

I'm willing to pay you for an hour of your time or so to walk me through this if you are up for it?

Jonovono commented 1 year ago

I added this:

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

Seems to have gotten past that error, but now get this:

Node: 'deeplabv3plus/tf.compat.v1.nn.depthwise_conv2d_80/depthwise/SpaceToBatchND'
padded_shape[0]=32 is not divisible by block_shape[0]=6
     [[{{node deeplabv3plus/tf.compat.v1.nn.depthwise_conv2d_80/depthwise/SpaceToBatchND}}]] [Op:__inference_train_function_37058]
RichardLindhout commented 7 months ago

@mberkay0 Can I contact you privately?