Last active
April 5, 2020 18:46
-
-
Save wlinInspire/6c6ddc66c9afa103002f2874f19819d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pickle | |
import caffe | |
import cv2 | |
import numpy as np | |
# ====================================================================================================================== | |
# Off load params for each net in a pickle file | |
# ====================================================================================================================== | |
dnn_model = cv2.dnn.readNetFromCaffe('opencv_face_detector.prototxt', | |
'opencv_face_detector_model.caffemodel') | |
layers = ['data_bn', 'data_scale', 'conv1_h', 'conv1_bn_h', 'conv1_scale_h', | |
'layer_64_1_conv1_h', 'layer_64_1_bn2_h', 'layer_64_1_scale2_h', | |
'layer_64_1_conv2_h', 'layer_128_1_bn1_h', 'layer_128_1_scale1_h', | |
'layer_128_1_conv1_h', 'layer_128_1_bn2', 'layer_128_1_scale2', | |
'layer_128_1_conv2', 'layer_128_1_conv_expand_h', 'layer_256_1_bn1', | |
'layer_256_1_scale1', 'layer_256_1_conv1', 'layer_256_1_bn2', | |
'layer_256_1_scale2', 'layer_256_1_conv2', 'layer_256_1_conv_expand', | |
'layer_512_1_bn1', 'layer_512_1_scale1', 'layer_512_1_conv1_h', | |
'layer_512_1_bn2_h', 'layer_512_1_scale2_h', 'layer_512_1_conv2_h', | |
'layer_512_1_conv_expand_h', 'last_bn_h', 'last_scale_h', 'conv6_1_h', | |
'conv6_2_h', 'conv7_1_h', 'conv7_2_h', 'conv8_1_h', 'conv8_2_h', | |
'conv9_1_h', 'conv9_2_h', 'conv4_3_norm', 'conv4_3_norm_mbox_loc', | |
'conv4_3_norm_mbox_conf', 'fc7_mbox_loc', 'fc7_mbox_conf', | |
'conv6_2_mbox_loc', 'conv6_2_mbox_conf', 'conv7_2_mbox_loc', | |
'conv7_2_mbox_conf', 'conv8_2_mbox_loc', 'conv8_2_mbox_conf', | |
'conv9_2_mbox_loc', 'conv9_2_mbox_conf'] | |
params_opencv = {} | |
for layer in layers: | |
params_opencv[layer] = dnn_model.getLayer(layer).blobs | |
with open('params_opencv', 'wb') as f: | |
pickle.dump(params_opencv, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment