GenderThread.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:live-age-gender-estimator 作者: taipalma 项目源码 文件源码
def __init__(self, videoThread):

        threading.Thread.__init__(self)

        print "Initializing recognition thread..."
        self.videoThread = videoThread

    #caffe.set_mode_cpu()
        caffe.set_mode_gpu()
        caffe.set_device(0)

        # Model file and parameters are written by trainDnn.py  
        # Take the most recent parameter set

    genderPath = "./dcnn_gender"
    genderParamFiles = glob.glob(genderPath + os.sep + "*.caffemodel")
        genderParamFiles = sorted(genderParamFiles, key=lambda x:os.path.getctime(x))

    MODEL_FILE_GENDER = genderPath + os.sep + "deploy_gender.prototxt"
        PRETRAINED_GENDER = genderParamFiles[-1]
        MEAN_FILE_GENDER = genderPath + os.sep + "mean.binaryproto"

    proto_data = open(MEAN_FILE_GENDER, 'rb').read()
        a = caffe.io.caffe_pb2.BlobProto.FromString(proto_data)
        mean  = caffe.io.blobproto_to_array(a)[0]

        # Initialize net             
        self.gender_net = caffe.Classifier(MODEL_FILE_GENDER, PRETRAINED_GENDER, image_dims=(227,227),)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号