pythonlessons / mltu

Machine Learning Training Utilities (for TensorFlow and PyTorch)
MIT License
160 stars 100 forks source link

ValueError: The filepath provided must end in `.keras` (Keras model format). Received: filepath=Models/02_captcha_to_text/202403291006/model.h5 #48

Open keosaly opened 3 months ago

keosaly commented 3 months ago

Hello, Can you help me to fix this?

ValueError: The filepath provided must end in .keras (Keras model format). Received: filepath=Models/02_captcha_to_text/202403291006/model.h5

keosaly commented 3 months ago

my code:

Define callbacks

earlystopper = EarlyStopping(monitor="val_CER", patience=50, verbose=1, mode="min") checkpoint = ModelCheckpoint(f"{configs.model_path}/model.h5", monitor="val_CER", verbose=1, save_best_only=True, mode="min") trainLogger = TrainLogger(configs.model_path) tb_callback = TensorBoard(f"{configs.model_path}/logs", update_freq=1) reduceLROnPlat = ReduceLROnPlateau(monitor="val_CER", factor=0.9, min_delta=1e-10, patience=20, verbose=1, mode="min") model2onnx = Model2onnx(f"{configs.model_path}/model.h5")

Train the model

model.fit( train_data_provider, validation_data=val_data_provider, epochs=configs.train_epochs, callbacks=[earlystopper, checkpoint, trainLogger, reduceLROnPlat, tb_callback, model2onnx], workers=configs.train_workers )

Save training and validation datasets as csv files

train_data_provider.to_csv(os.path.join(configs.model_path, "train.csv")) val_data_provider.to_csv(os.path.join(configs.model_path, "val.csv"))

mbahadirk commented 1 month ago

did you find any solutions on that? I'am still working on that

pythonlessons commented 1 month ago

It seems you try to use newest tensorflow version (different from tutorial). Recommend to downgrade tensorflow for compatibility. Otherwise you need to do changes manualy. For example change model.h5 to model.keras in all places. But you may face more serious incompatibilities further