image-segmentation-keras
image-segmentation-keras copied to clipboard
AssertionError: Checkpoint not found.
assert (latest_weights is not None), "Checkpoint not found."
AssertionError: Checkpoint not found. What should I do?please, help me!
Hi, I have the same issue. Did you find out what to do?
latest_weights = find_latest_checkpoint(checkpoints_path) Let's change the absolute path
Where did you put this line of code? Do you also have this as output in checkpoints: checkpoint.0 checkpoint.1 checkpoint.2 checkpoint.3 checkpoint.4 checkpoint_config.json
Where checkpoint is the name you gave the model.
I see now this is a line of code in the error. How did you change the absolute path? I tried a lot and I think I have the right path as checkpoints_path but I still get the error.
I solved this problem, you can load the model without using the function written by the author, maybe there are some bugs in it, right?The solution is as follows: in keras_segmentation/models/predict.py Comment out the following code:
Assert (os.path.isfile(checkpoints_path+"_config.json"), "Checkpoint not found."
Model_config = json. Loads (open (checkpoints_path + "_config. Json", "r"), read ())
To:
Model_config = json. Loads (open (". / checkpoints/vgg_unet_1_config. Json ", "r"), read ())
Inside the quotes is the path to your json file, either absolute or relative
The same thing with this one:
Latest_weights = find_latest_checkpoint (checkpoints_path)
To:
Latest_weights = "checkpoints/vgg_unet_1. 22"
Use your model file in quotes and use whatever model you want
@JensBB Are you using Windows? What are your packages versions? Especially tensorflow and keras versions
This error appears to me sometimes, but as @lyc1995452-star point, it gets resolved changing the path, for example, from /machine/home/path/to/checkpoints
to /path/to/checkpoints
. Although this comment is not a solution, mostly because my ignorance about sys path python behavior, I doubt is a code bug
@JaledMC I didn't manage to make it work by changing the path. However, I save the model weights. For example for a vgg_unet:
model.save('Saved_models/vgg_unet.h5')
This can then be loaded by importing the model and assigning the weights to it.
from keras_segmentation.models.unet import vgg_unet
model1 = vgg_unet(n_classes=2 , input_height=224, input_width=224 )
model1.load_weights('Saved_models/vgg_unet.h5')
For everyone having this error, you can also use this!
JB
From the Beginner's guide:
predict(
checkpoints_path="checkpoints/vgg_unet_1",
inp="dataset_path/images_prepped_test/0016E5_07965.png",
out_fname="output.png"
)
If you are on Windows, it may result in this error:
AssertionError: Checkpoint not found.
Try the following to solve the issue:
predict(
checkpoints_path="checkpoints\\vgg_unet_1",
inp="dataset_path/images_prepped_test/0016E5_07965.png",
out_fname="output.png"
)
I have the same problem
find_latest_checkpoint
function is looking for file named in format [name].[epoch]
, but i have only [name].[epoch].data-00000-of-00001
and [name].[epoch].index
files.
find_latest_checkpoint function is looking for file named in format [name].[epoch], but i have only [name].[epoch].data-00000-of-00001 and [name].[epoch].index files.
I had the same issue but solved it. The cause was the version of Tensorflow.
I'm not able to read Tensorflow 2.0 checkpoint files, but I've noticed that I can read Tensorflow 1.4 checkpoints.
So the solution is to uninstall Tensorflow 2.0 and install Tensorflow 1.4.
Hi, this have been fixed now.
You can uninstall the existing keras_segmentation and install the master branch using : pip install git+https://github.com/divamgupta/image-segmentation-keras
That should solve the error.
Hi! You can still reproduce this issue by using "/" instead of "" in the checkpoints_path. The code will recognize the .json file, but the "assert (latest_weights is not None), "Checkpoint not found."" error message still will halt the run. It can problem, if are not using the Command Line Interface.
After doing this small modification in the path, it's working well. But you may also encounter this error, so I will just leave it here. --checkpoints_path="...somefolder/something/vgg_latest_trained_network_config" (bad) --checkpoints_path="...somefolder\something\vgg_latest_trained_network_config" (good)