-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Can Detectron model be converted to Caffe model? #600
Comments
@dedoogong First I have to say I do not know a lot of things about this issue.
1. Get a Caffe2 model
Could you provide the exact command you you run to convert the pkl ? This seems very suspicious to me, and if something is wrong I want to correct my PR. 2. Convert this Caffe2 model to a Caffe model
Can you provide a sample code on how to do that ? How do you keep the structure of the net ? Is it the prototxt file ? Is it sufficient ? For what it's worth, this comment seems to show a sort of solution here but it does not look like there is a direct and obvious way. facebookarchive/caffe2#641 (comment) |
@gadcam thank you for your detailed reply. Current Status: 1. Get a Caffe2 model
my command is : results: Your PR looks good, maybe there is my mistake. By the way, when I downloaded some demo example pb files here, those are also so small like that. Maybe the small size is a nomal result? 2. 3rd converting tools
I just meant that I can access each weights of layers and handle it as numpy arrays. And yes I made a new prototxt file manually from the generated pbtxt but I will write a script later. name: "detectron_keypoint_net" input: "data" layer { layer {
Yes. ONNX is such a awesome tool, but when I tried to convert a tensorflow model to caffe before, it run slower almost 10 times(both running based on cuDNN layers). 3. Hyper paramerters num_output: After loading the model file and I checked the each blob size of total net(keypoint_net, body net) and filled each num_output value in the .prototxt one by one manually. lr_mult, decay_mult: As I just want to run inference step, I don't need those. 4. Newly added layers IMO, for running Detectron on Caffe, the newly added operators also need to be ported. ResizeNearst(upsample_nearest_op.cu) -> Done! |
Regarding 1. Get a Caffe2 model
I just tried it and it worked for me. I used a fresh install from current version of the repository + #449 (+ #110 Python3 compatibility fix). The output looks like this for me
|
ok ;) thank you for your help!! |
@dedoogong Thanks! |
I want to run Keypoint RCNN on an embedded board(not TX1 or 2, but another powerful DSP board that can run RFCN or Faster RCNN model in real time) after model quantization and some optimization. Unfortunately it supports only Caffe 1.
After merging PR #372 and #449, I'm struggling to convert Keypoint-R-CNN example model to Caffe.
By default, Detectron divides the model into "base" part and "head" part, but I made a new Caffe prototxt including both keypoint net and net(base net) after extracting detectron_net.pbtxt and detectron_keypoint_net_pbtxt together and manually changed each name of items.
Also, I found it's possible to convert all of Caffe2's weight/bias to numpy arrays and then those to Caffe using FetchBlob("weight name").
But now, I feel confused that it seems like, there would be no matching CUDA/cuDNN implementation in Caffe2 for Caffe's "Deconvolution(gpu)" code( Does "ConvTranspose" work same as "Deconvolution"?)
Should I port each newly implemented gpu operators in Caffe2 to Caffe's layer? BatchPermutation gpu operator in Caffe2 also doesn't exist in Caffe. Oh, I don't want to open Hell Gate.
Plus, some of Caffe's hyper parameters in prototxt are gone in Caffe2's pbtxt such as " num_output" or "lr_mult" in convolution_param. How can I infer num_output values? or how can I apply lr_mult /decay_mult? Can I just ignore those old version parameters?
Not only that, Detectron's convert_pkl_to_pb.py converts the example weight file(.pkl, arond 480MB) to so small 2 .pb files(less than 200KB in total) with fusing AffineTransform option. If I apply this fusing option, it merge some blobs, so the original network structure is changed and reduced. As there is no AffineTransform layer in Caffe, I need to turn on this option.
So, I would like someone to tell me that Caffe2 can be translated to Caffe or not.
Is there anybody who succeed in converting Caffe2 model to Caffe?
I'm also considering ONNX or MMdnn, but it seems like, those converting tools insert too many interface layers that make it run so slowly! So, I want to convert directly from Detectron/Caffe2 to Caffe using numpy!
Thank you in advance!
System information
Operating system: ubuntu 16.04
Compiler version: gcc 5.4.0
CUDA version: 9.2
cuDNN version: 7.1.4
NVIDIA driver version: 396.45
GPU models (for all devices if they are not all the same): GTX 1080
PYTHONPATH
environment variable: /home/lee/caffe2-pytorch/build:/usr/local:/usr/local/lib/python3.5/site-packages:/usr/local/lib/python3.5/dist-packages:/home/lee/Downloads/light_head_rcnn/lib:/home/lee/Downloads/pyRFCN/py-R-FCN/lib:/home/lee/Downloads/pyRFCN/py-R-FCN/caffe/python:python --version
output: python3.5The text was updated successfully, but these errors were encountered: