from tensorflow.keras.callbacks import ModelCheckpoint if not os.path.exists(PROJECT_PATH + '/checkpoints/'): os.makedirs(PROJECT_PATH + '/checkpoints/') cp= ModelCheckpoint(PROJECT_PATH + '/checkpoints/model.h5',monitor='val_accuracy', save_best_only=True,verbose=1)