Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save a MASK RCNN model after training?

I am using matterport repository to train MASK RCNN on a custom dataset. I have been successful in training. Now I want to save the trained model and use it in a web application to detect objects. How do I save the mask rcnn model after training? Please guide me.

The link of the repository:

https://github.com/matterport/Mask_RCNN

like image 974
anmol narang Avatar asked Nov 07 '22 15:11

anmol narang


1 Answers

Based on this discussion on GitHub, it appears that trained model or weights of matterport/Mask RCNN can be saved as a JSON file in a manner similar to those trained via standard Keras:

import keras
import json

def save_model(trained_model, out_fname="model.json"):
    jsonObj = trained_model.keras_model.to_json()
    with open(out_fname, "w") as fh:
        fj.write(jsonObj)
 
save_model(model, "mymodel.json")

Update: If you run into the error related to thread-like object, you might find this post helpful...

like image 89
David C. Avatar answered Nov 14 '22 14:11

David C.