The Mask-RCNN model outputs for a single inference image.
My eventual goal is to export a Mask-RCNN that I fine-tuned on my own dataset for deployment, but to start with I'm just trying to export a standard pre-trained COCO Mask-RCNN, as is shown in the example.
and the script executed successfully, ran inference through several test images, and created a directory caffe2_model, containing several files: coco_instances_results.json instances_predictions.pth model_init.pb model.pb model.pbtxt
I wrote the following python script to try to make use of the above exported model files:
run_model.py:
from caffe2.python import core, workspace, model_helper, utils, brew
import numpy as np
import cv2
print('Imported stuff')
IMAGE_PATH = '1acb46f2-b23f-4696-8049-180ce25e0b51.18aecbee-2d62-4e4d-a527-8e99cc9d74e8.jpg'
with open("model_init.pb", "rb") as f:
init_net = f.read()
with open("model.pb", "rb") as f:
predict_net = f.read()
print('Loaded model files')
p = workspace.Predictor(init_net, predict_net)
print('Created a predictor')
SIZE = 224
img = cv2.imread(IMAGE_PATH)
img = cv2.resize(img, (SIZE, SIZE), cv2.INTER_CUBIC)
img = np.reshape(img, (3, SIZE, SIZE))
img = np.float32(np.expand_dims(img, axis=0))
print('Loaded & preprocessed the test image')
print('INput shape: ', img.shape)
print('Forward passing the net...')
results = p.run({'data': img})
print('Forward passed the net')
print(results)
Expected results
The Mask-RCNN model outputs for a single inference image.
My eventual goal is to export a Mask-RCNN that I fine-tuned on my own dataset for deployment, but to start with I'm just trying to export a standard pre-trained COCO Mask-RCNN, as is shown in the example.
Actual results
Detailed steps to reproduce
First I followed the instructions here https://github.com/facebookresearch/detectron2/blob/master/docs/tutorials/deployment.md#usage
and the script executed successfully, ran inference through several test images, and created a directory
caffe2_model
, containing several files:coco_instances_results.json instances_predictions.pth model_init.pb model.pb model.pbtxt
I wrote the following python script to try to make use of the above exported model files:
run_model.py:
System information
PYTHONPATH
environment variable::/home/sal9000/Sources/tensorflow/models/research/:/home/sal9000/Sources/tensorflow/models/research/slim
python --version
output: Python 3.6.9