darknet.py 文件源码

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

项目:pytorch-caffe-darknet-convert 作者: marvis 项目源码 文件源码
def __init__(self, cfgfile):
        super(Darknet, self).__init__()
        self.blocks = parse_cfg(cfgfile)
        self.models = self.create_network(self.blocks) # merge conv, bn,leaky
        self.loss = self.models[len(self.models)-1]

        self.width = int(self.blocks[0]['width'])
        self.height = int(self.blocks[0]['height'])

        if self.blocks[(len(self.blocks)-1)]['type'] == 'region':
            region_block = self.blocks[(len(self.blocks)-1)]
            anchors = region_block['anchors'].split(',')
            self.anchors = [float(i) for i in anchors]
            self.num_anchors = int(region_block['num'])
            self.anchor_step = len(self.anchors)/self.num_anchors
            self.num_classes = int(region_block['classes'])

        self.header = torch.IntTensor([0,0,0,0])
        self.seen = 0
        self.has_mean = False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号