Save the model as caffe2's protobuf format. Args: output_dir (str): the output directory to save protobuf files.
(self, output_dir)
| 222 | return self._init_net |
| 223 | |
| 224 | def save_protobuf(self, output_dir): |
| 225 | """ |
| 226 | Save the model as caffe2's protobuf format. |
| 227 | |
| 228 | Args: |
| 229 | output_dir (str): the output directory to save protobuf files. |
| 230 | """ |
| 231 | logger = logging.getLogger(__name__) |
| 232 | logger.info("Saving model to {} ...".format(output_dir)) |
| 233 | if not PathManager.exists(output_dir): |
| 234 | PathManager.mkdirs(output_dir) |
| 235 | |
| 236 | with PathManager.open(os.path.join(output_dir, "model.pb"), "wb") as f: |
| 237 | f.write(self._predict_net.SerializeToString()) |
| 238 | with PathManager.open(os.path.join(output_dir, "model.pbtxt"), "w") as f: |
| 239 | f.write(str(self._predict_net)) |
| 240 | with PathManager.open(os.path.join(output_dir, "model_init.pb"), "wb") as f: |
| 241 | f.write(self._init_net.SerializeToString()) |
| 242 | |
| 243 | def save_graph(self, output_file, inputs=None): |
| 244 | """ |