示例#1
0
    def __init__(self, model_config, weightfile, yolo):
        super(DarknetParser, self).__init__()

        if not os.path.exists(model_config):
            raise ValueError(
                'Darknet model config [{}] can not be found!'.format(
                    model_config))

        if weightfile:
            self.weight_loaded = True

        fp = open(weightfile, 'rb')
        header = np.fromfile(fp, count=4, dtype=np.int32)
        self.buf = np.fromfile(fp, dtype=np.float32)
        print("weights buf size: {}".format(self.buf.size))

        fp.close()

        if yolo == "1":
            self.start = 1  #yolov2
        else:
            self.start = 0  #yolov3 resnet

        model = parse_cfg(model_config)
        self.dk_graph = DarknetGraph(model)
        self.dk_graph.build()
示例#2
0
    def __init__(self, model_config, weightfile):
        super(DarknetParser, self).__init__()

        if not os.path.exists(model_config):
            raise ValueError(
                'Darknet model config [{}] can not be found!'.format(
                    model_config))
        # model = _cntk.Function.load(model)
        # print(model_config)
        if weightfile:
            # print(weight)
            self.weight_loaded = True

        # net_info = cfg2prototxt(model_config)
        # print(net_info)
        # save_prototxt(net_info , 'resnet50.prototxt', region=False)
        # net = caffe.Net('resnet50.prototxt', caffe.TEST)
        # params = net.params
        # print(params)

        fp = open(weightfile, 'rb')
        header = np.fromfile(fp, count=4, dtype=np.int32)
        self.buf = np.fromfile(fp, dtype=np.float32)
        print(self.buf.size)

        fp.close()
        self.start = 1

        model = parse_cfg(model_config)
        # print(model)
        self.dk_graph = DarknetGraph(model)
        self.dk_graph.build()