inisis / brocolli

Everything in Torch Fx
MIT License
341 stars 63 forks source link

KeyError: 'prim::PythonOp' while converting SSD300 with phase = "test" #42

Closed kv55 closed 2 years ago

kv55 commented 2 years ago

While I was trying to convert SSD300_vgg16 model to Caffe with phase = 'test' instead of 'export' I got the following error : File "/root/brocolli/converter/pytorch/pytorch_caffe_parser.py", line 138, in gen_IR node_type = layer_map[onnx_node_type] KeyError: 'prim::PythonOp'

inisis commented 2 years ago

While I was trying to convert SSD300_vgg16 model to Caffe with phase = 'test' instead of 'export' I got the following error :

File "/root/brocolli/converter/pytorch/pytorch_caffe_parser.py", line 138, in gen_IR

node_type = layer_map[onnx_node_type]

KeyError: 'prim::PythonOp'

can you provide your model. I have a ssd model under custom_models which can be coverted to caffe, you can follow it.

kv55 commented 2 years ago

I have used the ssd.py file in custom_models folder, but with some modifications. I have added detect and nms functions and also, some changes to handle version differences. In the test_caffe_nets.py file used build_ssd('test') instead of build_ssd('export'). ssd.zip

inisis commented 2 years ago

I have used the ssd.py file in custom_models folder, but with some modifications. I have added detect and nms functions and also, some changes to handle version differences. In the test_caffe_nets.py file used build_ssd('test') instead of build_ssd('export'). ssd.zip

Hi, right now you can only convert the backbone to caffe, if you want to convert priorbox and detection_out part, you should first convert model created by build_ssd('export'), then, you should fill this json by using your own parameter, https://github.com/inisis/brocolli/blob/2a15ac07010114716aef7fbb9be1f6d6b35e21a5/tests/example.json and use this https://github.com/inisis/brocolli/blob/2a15ac07010114716aef7fbb9be1f6d6b35e21a5/tests/ssd_layer.py to add priorbox and detection_out layer to your previously converted ssd backbone.

kv55 commented 2 years ago

I have used the ssd.py file in custom_models folder, but with some modifications. I have added detect and nms functions and also, some changes to handle version differences. In the test_caffe_nets.py file used build_ssd('test') instead of build_ssd('export'). ssd.zip

Hi, right now you can only convert the backbone to caffe, if you want to convert priorbox and detection_out part, you should first convert model created by build_ssd('export'), then, you should fill this json by using your own parameter, https://github.com/inisis/brocolli/blob/2a15ac07010114716aef7fbb9be1f6d6b35e21a5/tests/example.json and use this https://github.com/inisis/brocolli/blob/2a15ac07010114716aef7fbb9be1f6d6b35e21a5/tests/ssd_layer.py to add priorbox and detection_out layer to your previously converted ssd backbone.

Thank you so much for the suggestions. I could convert SSD in inference mode by following the above mentioned steps.

inisis commented 2 years ago

I have used the ssd.py file in custom_models folder, but with some modifications. I have added detect and nms functions and also, some changes to handle version differences. In the test_caffe_nets.py file used build_ssd('test') instead of build_ssd('export'). ssd.zip

Hi, right now you can only convert the backbone to caffe, if you want to convert priorbox and detection_out part, you should first convert model created by build_ssd('export'), then, you should fill this json by using your own parameter, https://github.com/inisis/brocolli/blob/2a15ac07010114716aef7fbb9be1f6d6b35e21a5/tests/example.json and use this https://github.com/inisis/brocolli/blob/2a15ac07010114716aef7fbb9be1f6d6b35e21a5/tests/ssd_layer.py to add priorbox and detection_out layer to your previously converted ssd backbone.

Thank you so much for the suggestions. I could convert SSD in inference mode by following the above mentioned steps.

Good for you