This repository was archived by the owner on Dec 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
This repository was archived by the owner on Dec 4, 2019. It is now read-only.
Error when running prediction #22
Copy link
Copy link
Open
Description
I am trying to run the prediction step on my CPU, using a model that is exported from Detectron
Script:
import time
from caffe2.proto import caffe2_pb2
from caffe2.python import core, workspace
from caffe2.python import dyndep
import detectron.utils.env as envu
import cv2
import numpy as np
def import_detectron_ops():
"""Import Detectron ops."""
detectron_ops_lib = envu.get_detectron_ops_lib()
dyndep.InitOpsLibrary(detectron_ops_lib)
import_detectron_ops()
predict_net = caffe2_pb2.NetDef()
with open('models/pb_frcnn/model.pb', 'rb') as f:
predict_net.ParseFromString(f.read())
init_net = caffe2_pb2.NetDef()
with open('models/pb_frcnn/model_init.pb', 'rb') as f:
init_net.ParseFromString(f.read())
# Load predictor
p = workspace.Predictor(init_net, predict_net)
img = cv2.imread('test/data/aofmknbaftbokjcg.png', \
cv2.IMREAD_COLOR).astype(np.float32) # Load image
img = img.swapaxes(1, 2).swapaxes(0, 1) # Switch to CHW
img = img[None, ...] # Add batch size
print(img.shape) # Print image shape
start_time = time.time()
results = p.run({'data': img})
end_time = time.time()
print(results)
print('Predict time:', (end_time-start_time), 'seconds')
Result:
Found Detectron ops lib: /home/fuzzybatman/.local/lib/python3.7/site-packages/torch/lib/libcaffe2_detectron_ops_gpu.so
(1, 3, 512, 512)
Traceback (most recent call last):
File "/home/fuzzybatman/Workspace/ET4399_Extra_Project_Okotech/02_Mask_RCNN/detectron/caffe2pred.py", line 38, in <module>
results = p.run({'data': img})
RuntimeError: [enforce fail at generate_proposals_op.cc:281] im_info_tensor.sizes() == (vector<int64_t>{num_images, 3}). [0] vs 1 3
Error from operator:
input: "rpn_cls_probs_fpn2" input: "rpn_bbox_pred_fpn2" input: "im_info" input: "anchor2" output: "rpn_rois_fpn2" output: "rpn_roi_probs_fpn2" name: "" type: "GenerateProposals" arg { name: "spatial_scale" f: 0.25 } arg { name: "pre_nms_topN" i: 12000 } arg { name: "post_nms_topN" i: 2000 } arg { name: "nms_thresh" f: 0.8 } arg { name: "min_size" f: 0 } arg { name: "correct_transform_coords" i: 1 } device_option { } engine: ""frame #0: std::function<std::string ()>::operator()() const + 0x11 (0x7faecbd06441 in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libc10.so)
frame #1: c10::ThrowEnforceNotMet(char const*, int, char const*, std::string const&, void const*) + 0x49 (0x7faecbd06259 in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libc10.so)
frame #2: <unknown function> + 0x1cbd5de (0x7faf0280e5de in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libcaffe2.so)
frame #3: <unknown function> + 0x1829345 (0x7faf0237a345 in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libcaffe2.so)
frame #4: caffe2::SimpleNet::Run() + 0x161 (0x7faf0244e101 in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libcaffe2.so)
frame #5: caffe2::Workspace::RunNet(std::string const&) + 0x3a (0x7faf024855aa in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libcaffe2.so)
frame #6: caffe2::Predictor::run_map_workspace(std::unordered_map<std::string, caffe2::Tensor, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, caffe2::Tensor> > > const&) + 0x242 (0x7faf024f1882 in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libcaffe2.so)
frame #7: caffe2::Predictor::operator()(std::unordered_map<std::string, caffe2::Tensor, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, caffe2::Tensor> > > const&, std::vector<caffe2::Tensor, std::allocator<caffe2::Tensor> >*) + 0x1f (0x7faf024f1cef in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/../../torch/lib/libcaffe2.so)
frame #8: <unknown function> + 0x53ccb (0x7faf0b17fccb in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-37m-x86_64-linux-gnu.so)
frame #9: <unknown function> + 0x92f7e (0x7faf0b1bef7e in /home/fuzzybatman/.local/lib/python3.7/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-37m-x86_64-linux-gnu.so)
<omitting python frames>
frame #22: __libc_start_main + 0xf3 (0x7faf2edd0f33 in /lib64/libc.so.6)
frame #23: _start + 0x2e (0x561f374f408e in /usr/bin/python3)
Are there dependencies that I am not loading?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels