Mask_rcnn: error with weights_path = model.find_last()

Created on 25 Aug 2018  ·  7Comments  ·  Source: matterport/Mask_RCNN

when i run“inspect_balloon_model.py”,it reports error:

Traceback (most recent call last):
File "/home/xupp/PycharmProjects/Mask_RCNN/samples/mountain/inspect_balloon_model.py", line 137, in
weights_path = model.find_last()
File "/home/xupp/PycharmProjects/Mask_RCNN/mrcnn/model.py", line 2099, in find_last
errno.ENOENT, "Could not find weight files in {}".format(dir_name))
FileNotFoundError: [Errno 2] Could not find weight files in /home/xupp/PycharmProjects/Mask_RCNN/logs/balloon20180825T1144

Actually i have trained my own model by ”balloon.py“ and a logs file has been generated

Most helpful comment

The suggestion made by @rohanricky did not work for me, as the error is occurring before model.find_last() returns. Seems to me that for some reason the code creates a new logging sub-directory before actually looking up the check point. A quick fix for this is changing this part:

https://github.com/matterport/Mask_RCNN/blob/41e7c596ebb83b05a4154bb0ac7a28e0b9afd017/mrcnn/model.py#L2091

Specifically, replace the index of the list so that it returns not the last directory value, but the second to last

dir_name = os.path.join(self.model_dir, dir_names[-2])

All 7 comments

model.find_last() gives a list containing ['/home/xupp/PycharmProjects/Mask_RCNN/logs/balloon20180825T1144', '/home/xupp/PycharmProjects/Mask_RCNN/logs/balloon20180825T1144/{your_h5_file}.h5']
So, the code should be weights_path = model.find_last()[1]

thanks!

At 2018-08-26 01:51:59, "Rohan Kothapalli" notifications@github.com wrote:

model.find_last() gives a list containing ['/home/xupp/PycharmProjects/Mask_RCNN/logs/balloon20180825T1144', '/home/xupp/PycharmProjects/Mask_RCNN/logs/balloon20180825T1144/{your_h5_file}.h5']
So, the code should be weights_path = model.find_last()[1]


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

The suggestion made by @rohanricky did not work for me, as the error is occurring before model.find_last() returns. Seems to me that for some reason the code creates a new logging sub-directory before actually looking up the check point. A quick fix for this is changing this part:

https://github.com/matterport/Mask_RCNN/blob/41e7c596ebb83b05a4154bb0ac7a28e0b9afd017/mrcnn/model.py#L2091

Specifically, replace the index of the list so that it returns not the last directory value, but the second to last

dir_name = os.path.join(self.model_dir, dir_names[-2])

Just merged a PR today that fixes this issue. Sorry for the trouble. Please try the latest commit.

I think this is still an issue. I am getting the error again and don't see the change reflected in the library source code

I also have an error like that. I try to follow as all of above advises but it doesn't work for me. Please advise me what I should do.

@may-phyu , if none of the above suggestions worked you'd want to give this a try - when you are loading the trained model using model.find_last(), make sure the starting 'n' letters of the name of the saved model (i.e. under logs/ folder per see) matches with the string value assigned to NAME attribute in class BalloonConfig of the Balloon.py file.

For instance, let's assume that you have given blueballoon as your configuration name in balloon.py file

class BalloonConfig(config):
# Give the configuration a recognizable name
NAME = "blueballoon"

Then in this case, when you load your trained model using model.find_last(), it will look for a subfolder starting with the name blueballoon under the logs folder.

Hope this helps?

P.S. I know I'm answering after almost a year and probably you might have already found a fix.. in case, you did, do share the solution with us :)

Was this page helpful?
0 / 5 - 0 ratings