From fdc0147acd6944858f436310aa3c98e6c4664e7d Mon Sep 17 00:00:00 2001 From: abedalbaset Date: Sun, 12 May 2024 11:10:49 +0300 Subject: [PATCH] Update README.md --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index acdb72db..521d88cf 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,33 @@ python -m keras_segmentation train \ Choose model_name from the table above +### Save and load the model +To save model , the checkpoint path will auto save model , but in case got error about .h5 extention you can modify the train.py line 184 from .{epoch:05d} to .weights.h5 +and checkpoint path to include file name ex: checkpoints_path = "checkpoint_dir/filename" +then to load the model again later : +```shell +from keras_segmentation.pretrained import model_from_checkpoint_path + +model_config = { + + "input_height": , + "input_width": , + "n_classes": , + "model_class": "vgg_unet", + + } + +model = model_from_checkpoint_path(model_config, "checkpoint/t.weights.h5") + +resimg = model.predict_segmentation("target_dataset/big_images/big_1.jpg") +#resimg = model.predict_segmentation("farm/farm.jpg") + +# Display the segmented image +plt.imshow(resimg) +plt.axis('off') # Turn off axis +plt.show() + +``` ### Getting the predictions