This is a tiny example for converting fastreid-baseline in `meta_arch` to Caffe model, if you want to convert more complex architecture, you need to customize more things.
then you can check the Caffe model and prototxt in `logs/caffe_model`.
3. Change `prototxt` following next three steps:
1) Edit `max_pooling` in `baseline_R50.prototxt` like this
```prototxt
layer {
name: "max_pool1"
type: "Pooling"
bottom: "relu_blob1"
top: "max_pool_blob1"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
pad: 0 # 1
# ceil_mode: false
}
}
```
2) Add `avg_pooling` right place in `baseline_R50.prototxt`
```prototxt
layer {
name: "avgpool1"
type: "Pooling"
bottom: "relu_blob49"
top: "avgpool_blob1"
pooling_param {
pool: AVE
global_pooling: true
}
}
```
3) Change the last layer `top` name to `output`
```prototxt
layer {
name: "bn_scale54"
type: "Scale"
bottom: "batch_norm_blob54"
top: "output" # bn_norm_blob54
scale_param {
bias_term: true
}
}
```
4. (optional) You can open [Netscope](https://ethereon.github.io/netscope/quickstart.html), then enter you network `prototxt` to visualize the network.
5. Run `caffe_inference.py` to save Caffe model features with input images
6. Run `demo/demo.py` to get fastreid model features with the same input images, then compute the cosine similarity of difference model features to verify if you convert Caffe model successfully.
Thank to [CPFLAME](https://github.com/CPFLAME), [gcong18](https://github.com/gcong18), [YuxiangJohn](https://github.com/YuxiangJohn) and [wiggin66](https://github.com/wiggin66) at JDAI Model Acceleration Group for help in PyTorch to Caffe model converting.