-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Community effort to bring CPU and pure Caffe2 / C++ inference support #432
Comments
Based on #372, models containing FPN can be correctly converted to caffe2's .pb files. (I will rebase the PR on master soon) However only detection net will be converted even in Mask R-CNN and Keypoint R-CNN which has mask net or keypoint net. |
@daquexian I am really sorry but I think I failed to understand properly what you mean as I do not have a deep understanding how the Detectron repo works. Do you mean that, when #372 will be merged, if we try to convert for example e2e_keypoint_rcnn_R-50-FPN_1x only the proposal part would be converted and so we could not use it on CPU ? |
@gadcam If we try to convert e2e_keypoint_rcnn_R-50-FPN_1x, we will only get bounding boxes but not keypoint. Because in here only |
@daquexian would you like to write a detail guild on how to change pkl to pb? Thanks |
@HappyKerry Just fetch and checkout my branch
and run |
@daquexian I ran For
If I try to convert
So I have a few questions
|
@daquexian Then that is perfect : I did use the models in the Model Zoo.
Why did you suspect I tried to convert something else ? Because I have some |
@gadcam Yes. It is reasonable that Could you please tell me what |
I meant
I am not sure I got this part : do you mean that when we see So I think we are getting to the point of my issue : what should we implement to avoid it ? Or can you direct me where to dive to know what we need to implement ? If we take an example (but we could say the same thing for
The only mention I found of Detectron/detectron/roi_data/fast_rcnn.py Line 103 in b3c93df
So I do not really know where to investigate to avoid this Blob ____ is not supported error.
As a side question should we implement something like
|
@gadcam Detectron/tools/convert_pkl_to_pb.py Line 558 in b3c93df
('data' and 'im_info' are the inputs of model.net, 'fpn_res2_2_sum', 'keypoint_rois_fpn2' and so on are the inputs of model.keypoint_net) The converted model will crash when you try to verify it. Because its inputs are not legal. Maybe giving it some proper inputs ('fpn_res2_2_sum' and so on produced by bbox branch, and also "keypoint_rois_fpnX" below) will make it run. Detectron/detectron/core/test.py Lines 540 to 566 in b3c93df
|
@daquexian Thank you for your hints, with a bit of work I was able to run |
@gadcam Great! Looking forward to your PR |
@gadcam Hi, are we able to convert the Mask R-CNN model from |
@dongmingsun With @daquexian's #372 + my (future) PR you will be able to convert the models from the Zoo from |
@gadcam Thank you very much, so I still have to figure out how to feed a Detectron model to pure Caffe2 C++. |
@gadcam Hi, do you encounter this problem when you ran
|
Hi @kundalee , it seems that your caffe2 version is not the latest. You might want to
pull the latest code from https://github.com/pytorch/pytorch and recompile it.
…On Wed, May 23, 2018, 12:10 PM Kunda ***@***.***> wrote:
@gadcam <https://github.com/gadcam> Hi, do you encounter this problem
when you ran convert_pkl_to_pb.py in @daquexian
<https://github.com/daquexian> .
Cannot find operator schema for CollectAndDistributeFpnRpnProposals. Will
skip schema checking.
Traceback for operator 164 in network origin_model
Traceback (most recent call last):
File "tools/convert_pkl_to_pb.py", line 637, in
main()
File "tools/convert_pkl_to_pb.py", line 631, in main
verify_model(args, [net, init_net], args.test_img)
File "tools/convert_pkl_to_pb.py", line 569, in verify_model
_run_cfg_func, _run_pb_func, test_img, check_blobs)
File
"/alpha/Rddd/projects/detectron0518/Detectron/detectron/utils/model_convert_utils.py",
line 367, in compare_model
res2 = model2_func(test_image, check_blobs)
File "tools/convert_pkl_to_pb.py", line 565, in _run_pb_func
return run_model_pb(args, model_pb[0], model_pb[1], im, check_blobs)
File "tools/convert_pkl_to_pb.py", line 505, in run_model_pb
workspace.CreateNet(net)
File
"/home/Rddd/data/projects/caffe2/build-cpu/caffe2/python/workspace.py",
line 163, in CreateNet
StringifyProto(net), overwrite,
File
"/home/Rddd/data/projects/caffe2/build-cpu/caffe2/python/workspace.py",
line 189, in CallWithExceptionIntercept
return func(*args, **kwargs)
RuntimeError: [enforce fail at operator.cc:191] op. Cannot create operator
of type 'CollectAndDistributeFpnRpnProposals' on the device 'CPU'. Verify
that implementation for the corresponding device exist. It might also
happen if the binary is not linked with the operator implementation code.
If Python frontend is used it might happen if dyndep.InitOpsLibrary call is
missing. Operator def: input: "rpn_rois_fpn2" input: "rpn_rois_fpn3" input:
"rpn_rois_fpn4" input: "rpn_rois_fpn5" input: "rpn_rois_fpn6" input:
"rpn_roi_probs_fpn2" input: "rpn_roi_probs_fpn3" input:
"rpn_roi_probs_fpn4" input: "rpn_roi_probs_fpn5" input:
"rpn_roi_probs_fpn6" output: "rpn_rois" output: "rois_fpn2" output:
"rois_fpn3" output: "rois_fpn4" output: "rois_fpn5" output:
"rois_idx_restore_int32" name: "" type:
"CollectAndDistributeFpnRpnProposals" arg { name: "roi_max_level" i: 5 }
arg { name: "rpn_post_nms_topN" i: 1000 } arg { name: "roi_canonical_scale"
i: 224 } arg { name: "rpn_min_level" i: 2 } arg { name:
"roi_canonical_level" i: 4 } arg { name: "roi_min_level" i: 2 } arg { name:
"rpn_max_level" i: 6 } device_option { } engine: "" debug_info: " File
"tools/convert_pkl_to_pb.py", line 637, in \n main()\n File
"tools/convert_pkl_to_pb.py", line 607, in main\n convert_net(args,
net.Proto(), blobs)\n File "tools/convert_pkl_to_pb.py", line 279, in
convert_net\n convert_op_in_proto(net, convert_python)\n File
"/alpha/Rddd/projects/detectron0518/Detectron/detectron/utils/model_convert_utils.py",
line 113, in convert_op_in_proto\n convert_op_in_ops(proto.op,
func_or_list)\n File
"/alpha/Rddd/projects/detectron0518/Detectron/detectron/utils/model_convert_utils.py",
line 102, in convert_op_in_ops\n new_ops = func(op)\n File
"/alpha/Rddd/projects/detectron0518/Detectron/detectron/utils/model_convert_utils.py",
line 76, in wrapper\n return f(op, **params)\n File
"tools/convert_pkl_to_pb.py", line 250, in convert_python\n
rpn_post_nms_topN=cfg.TEST.RPN_POST_NMS_TOP_N,\n File
"tools/convert_pkl_to_pb.py", line 158, in convert_collect_and_distribute\n
rpn_post_nms_topN=rpn_post_nms_topN,\n"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#432 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALEcn4FWwcu0YBA_OdHH_XwLx1Ba1Wogks5t1OErgaJpZM4T_faM>
.
|
@gadcam @daquexian @dongmingsun I have changed pkl model to pb model,but how to use pb model in caffe2 C++? Thanks |
@HappyKerry you can search for caffe2 android demo or thiry-party tutorials |
@HappyKerry caffe2_cpp_tutorial might helps. |
Hi @daquexian Thank you very much. Because of you comments, the problem But when I try to load the pb files for testing on CPU, i get this problem below. Everything is fine until I call this function
I have noticed that the function named |
@kundalee Detectron/detectron/utils/c2.py Line 42 in e5bb3a8
And I haven't find how to load module in c++. No one responds to my issue (It's so normal :D) So I compiled the detectron ops into caffe2 main library as a workaround. |
@daquexian I met the same "BatchPermutation"problem as @kundalee, So how to compile the detectron ops into caffe2 main library ? |
@HappyKerry Just copy detectron ops into the main caffe2 ops directory and recompile. |
Assuming that #372 & #449 are correct and merged. def run_model_pb(args, models_pb, im, check_blobs):
workspace.ResetWorkspace()
net, init_net = models_pb
workspace.RunNetOnce(init_net)
mutils.create_input_blobs_for_net(net.Proto())
workspace.CreateNet(net)
input_blobs = _prepare_blobs(
im,
cfg.PIXEL_MEANS,
cfg.TEST.SCALE, cfg.TEST.MAX_SIZE
)
boxes = ????
if cfg.MODEL.MASK_ON:
im_scale = input_blobs['im_info'][0][2]
mask_rois = {'mask_rois': test._get_rois_blob(boxes, im_scale)}
# Add multi-level rois for FPN
if cfg.FPN.MULTILEVEL_ROIS:
test._add_multilevel_rois_for_test(mask_rois, 'mask_rois')
input_blobs.update(keypoints_rois)
if cfg.MODEL.KEYPOINTS_ON:
im_scale = input_blobs['im_info'][0][2]
keypoints_rois = { 'keypoint_rois': test._get_rois_blob(boxes, im_scale)}
# Add multi-level rois for FPN
if cfg.FPN.MULTILEVEL_ROIS:
test._add_multilevel_rois_for_test(input_blobs, 'keypoint_rois')
input_blobs.update(keypoints_rois) But we can not know boxes before inference... As a sidenote why do we keep |
@daquexian I tried both gpu and cpu mode and got the following error. This one is got in CPU mode:
This one is got in GPU mode:
Do you have any idea how I can fix these? Thanks. |
@daquexian |
When I run
I trained the faster-rcnn model using the pretrained imagenet model, R-101.pkl. |
@gadcam Thank you for the effort.
How to use the pb files in python? is there somewhere a tutorial/example? (i couldn't find something useful yet) |
Hi! @daquexian @HappyKerry @kundalee
Does it mean that |
Hey I'm running
and getting the following error.
I've built caffe2 with CPU-only support. Is this going to be a deal breaker? Should I fire up the GPU version and convert to PB with that? Looks like one needs GPU support to convert from pkl to pb. Is this assumption I'm making correct? |
Hi,I have converted .pkl model to .pb model under ubuntu16.04, and I want to use .pb in c++ windows.Do I need to install caffe2 under windows according to the tutorial https://caffe2.ai/docs/get-start.html? Platform=windows&configuration=compile? |
Is this finished? |
Hello @fuzzyBatman, To be honest I do not know what is the current state of the Detectron. |
Hello, did anyone come across this error? I did when I tried to run CPU-only C3D extraction. |
It looks like many people are asking for CPU inference and it seems it needs much work to make it happen. What I offer is that we use this issue to publicly state what work is needed and so people eager to have this feature could easily help to implement it.
@daquexian, @orionr, @rbgirshick do you have time to share a list of features / ops needed to convert all the models with convert_pkl_to_pb.py ?
I would like to contribute to this effort but I do not know where to begin.
If you are willing to implement a feature do not hesitate to tell it in this issue.
Ps: To avoid any confusion I am only a random user of the Detectron & my initiative was not solicited by the maintainers
The text was updated successfully, but these errors were encountered: