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
评论列表
文章目录