image-segmentation-keras icon indicating copy to clipboard operation
image-segmentation-keras copied to clipboard

AssertionError: Checkpoint not found.

Open lyc1995452-star opened this issue 4 years ago • 12 comments

assert (latest_weights is not None), "Checkpoint not found."

AssertionError: Checkpoint not found. What should I do?please, help me!

lyc1995452-star avatar Apr 19 '20 07:04 lyc1995452-star

Hi, I have the same issue. Did you find out what to do?

JensBB avatar Apr 21 '20 12:04 JensBB

latest_weights = find_latest_checkpoint(checkpoints_path) Let's change the absolute path

lyc1995452-star avatar Apr 21 '20 13:04 lyc1995452-star

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.

JensBB avatar Apr 21 '20 13:04 JensBB

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.

JensBB avatar Apr 21 '20 13:04 JensBB

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

Shiny-ZhangXiXin avatar Apr 27 '20 10:04 Shiny-ZhangXiXin

@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 avatar May 04 '20 08:05 JaledMC

@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

JensBB avatar May 04 '20 08:05 JensBB

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" 
)

nano360 avatar May 08 '20 13:05 nano360

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.

radekszostak avatar Jul 18 '20 09:07 radekszostak

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.

ma2bara avatar Aug 20 '20 01:08 ma2bara

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.

divamgupta avatar Sep 11 '20 03:09 divamgupta

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)

ujlaki15 avatar Apr 09 '21 14:04 ujlaki15