Args: dir (str): a directory used to save Caffe2Model with :meth:`save_protobuf`. The files "model.pb" and "model_init.pb" are needed. Returns: Caffe2Model: the caffe2 model loaded from this directory.
(dir)
| 264 | |
| 265 | @staticmethod |
| 266 | def load_protobuf(dir): |
| 267 | """ |
| 268 | Args: |
| 269 | dir (str): a directory used to save Caffe2Model with |
| 270 | :meth:`save_protobuf`. |
| 271 | The files "model.pb" and "model_init.pb" are needed. |
| 272 | |
| 273 | Returns: |
| 274 | Caffe2Model: the caffe2 model loaded from this directory. |
| 275 | """ |
| 276 | predict_net = caffe2_pb2.NetDef() |
| 277 | with PathManager.open(os.path.join(dir, "model.pb"), "rb") as f: |
| 278 | predict_net.ParseFromString(f.read()) |
| 279 | |
| 280 | init_net = caffe2_pb2.NetDef() |
| 281 | with PathManager.open(os.path.join(dir, "model_init.pb"), "rb") as f: |
| 282 | init_net.ParseFromString(f.read()) |
| 283 | |
| 284 | return Caffe2Model(predict_net, init_net) |
| 285 | |
| 286 | def __call__(self, inputs): |
| 287 | """ |