-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Support exporting for CPU Mask & Keypoint nets #449
Conversation
Pre-requisite : facebookresearch#372 Purpose : enable exporting all the models for CPU by exporting 2 separate nets : one for the bboxes and one for the rest of the inference. Two main modifications - Refactor the main() : it will call a function convert_to_pb for each sub_net - run_model_pb : always do the inference for bbox and then call mask or keypoint part if needed. The exact same approach is adopted. Then helper functions are only lightly modified to fit with the new objective to export 2 pb files
@daquexian I will more than welcome a review from you on this pull request if you have some time to put into it. |
@daquexian @ir413 @rbgirshick @orionr |
We have open sourced the operator for keypoint (https://github.com/pytorch/pytorch/blob/master/caffe2/operators/heatmap_max_keypoint_op.cc) that it is now feasible to convert the keypoint model to a single caffe2 model. |
@newstzpz thank you! That is really good to hear! @ir413 @rbgirshick do you plan to change the code of the master to provide a way to run directly using a single model ? (with a CFG parameter ?) If I want to enable exporting a single caffe2 model for keypoint inference what is the best way to proceed ? |
Hi @gadcam , I tried implementing this branch to obtain the .pb files for the e2e_mask_rcnn_R-101-FPN_2x.yaml config file with the --device as cpu. How do I integrate the two to provide an e2e mask output from image data? |
@sidnav Currently It is a two stage process : If you only want to support mask models you can remove the part starting with if 'keypoint_net' in models_pb: |
@sidnav Yes you need to merge them.
I do not really know what you mean by that. |
@gadcam I merged the commits and tried implementing the GPU option to create the pb files. I get the following error - |
@sidnav Could you describe in detail what you are doing and also where is the error ? I do not have enough information to understand what is going on :)
The GPU to CPU conversion is implemented. |
Hi @gadcam, I run `convert_pkl_to_pb.py' with the device option set to gpu. I get the following error |
@sidnav Could you share these things please ?
I know I ask you a lot of things but if I can not reproduce the bug on my side I will have hard time to debug something I do not know. |
Converting GenerateProposals Python -> C++: anchors [[-22. -10. 25. 13.] anchors [[-40. -20. 47. 27.] anchors [[-84. -40. 99. 55.] anchors [[-164. -72. 195. 103.] anchors [[-332. -152. 395. 215.] Converting op CollectAndDistributeFpnRpnProposals output name: rois -> rpn_rois: Fusing affine channel...
|
@sidnav Everything is here |
@rbgirshick As #372 is in there is no more technical barrier to merge this one. @daquexian do not hesitate to make any remark, as you worked on the same piece of code it should be easier to check if there are any mistakes. |
@gadcam Thanks for working on this. Since we have open-sourced the heatmap_max_keypoint_op (a fast implementation of keypoint_utils.heatmaps_to_keypoints), and now we have the FPN support in pb, do you think it would be easier if we create a single model directly (instead of multiple pbs)? |
@newstzpz I started to modify this PR to merge the nets. Then, I will get to the heatmaps_to_keypoints question. I can not share the code now.
As you see there is a naming problem in the inputs/outputs names: keypoint_rois_fpn2 and rois_fpn2 should be the same (as I understand it at least) |
- WIP : the models run but there are differences in the results
@newstzpz @rbgirshick @ir413
It is running however I have different results from the original network. I am not able to find where I am wrong. Could you check the code ? Detectron/tools/convert_pkl_to_pb.py Lines 690 to 707 in 678ffa6
Ps: before this commit (and so trying to merge nets) the models had the same output |
@newstzpz @rbgirshick @ir413 Did you have time to have a look at the code ? |
Is there any update in this? |
@gadcam is your current version of pull request working? |
@gadcam I have merged your PL and was able to convert keypoints model to CPU.
Thank for you time! |
hi @sidnav Have u solved this issue? can you post the answer here.Thank you |
Looks like there is not enough interest in this work to eventually merge this PR or part of this work. |
Very helpful work! |
Prerequisite :
#372Purpose : enable exporting all the models for CPU by exporting 2 separate nets : one for the bboxes and one for the rest of the inference.
Two main modifications
Then helper functions are only lightly modified to fit with the new objective to export 2 pb files