資源簡介
以人群計數為例,對訓練好的MCNN caffe模型,調用caffe的python接口進行前向測試,輸出人群密度圖。詳細請參考博客:https://blog.csdn.net/u011285477/article/details/51954989
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
“““
Created?on?Tue?Mar?28?19:53:57?2017
@author:?lzhr
“““
#?crowd?counting?with?trained?model
import?init_path
import?caffe
import?tools
import?os.path?as?osp
import?numpy?as?np
from?caffe?import?layers?as?L?params?as?P?to_proto
import?matplotlib.pyplot?as?plt
from?PIL?import?Image
import?global_var?as?GV
import?matplotlib.image?as?mpimg
import?sys
import?h5py
import?scipy.io?as?sio
import?os
import?gc
import?time
import?math
import?cv2
#import?model
model_dir?=?‘/home/lzhr/MCNN_model/‘
prototxt?=?os.path.join(model_dir‘BRT_testdemo.prototxt‘)
#***********************************
caffemodel?=?os.path.join(model_dir‘BRT_iter_48000.caffemodel.h5‘)
useroi?=?0
#caffe.set_mode_cpu()
#set?up?the?net
caffe.set_mode_gpu()
caffe.set_device(0)
net?=?caffe.Net(prototxt?caffemodel?caffe.TEST)
#-------------------------test?station?crowd?counting---------
評論
共有 條評論