MCPcopy Index your code
hub / github.com/llSourcell/YOLO_Object_Detection / cfg_yielder

Function cfg_yielder

darkflow/utils/process.py:62–321  ·  view source on GitHub ↗

yielding each layer information to initialize `layer`

(model, binary)

Source from the content-addressed store, hash-verified

60 return layers, meta
61
62def cfg_yielder(model, binary):
63 """
64 yielding each layer information to initialize `layer`
65 """
66 layers, meta = parser(model); yield meta;
67 h, w, c = meta['inp_size']; l = w * h * c
68
69 # Start yielding
70 flat = False # flag for 1st dense layer
71 conv = '.conv.' in model
72 for i, d in enumerate(layers):
73 #-----------------------------------------------------
74 if d['type'] == '[crop]':
75 yield ['crop', i]
76 #-----------------------------------------------------
77 elif d['type'] == '[local]':
78 n = d.get('filters', 1)
79 size = d.get('size', 1)
80 stride = d.get('stride', 1)
81 pad = d.get('pad', 0)
82 activation = d.get('activation', 'logistic')
83 w_ = (w - 1 - (1 - pad) * (size - 1)) // stride + 1
84 h_ = (h - 1 - (1 - pad) * (size - 1)) // stride + 1
85 yield ['local', i, size, c, n, stride,
86 pad, w_, h_, activation]
87 if activation != 'linear': yield [activation, i]
88 w, h, c = w_, h_, n
89 l = w * h * c
90 #-----------------------------------------------------
91 elif d['type'] == '[convolutional]':
92 n = d.get('filters', 1)
93 size = d.get('size', 1)
94 stride = d.get('stride', 1)
95 pad = d.get('pad', 0)
96 padding = d.get('padding', 0)
97 if pad: padding = size // 2
98 activation = d.get('activation', 'logistic')
99 batch_norm = d.get('batch_normalize', 0) or conv
100 yield ['convolutional', i, size, c, n,
101 stride, padding, batch_norm,
102 activation]
103 if activation != 'linear': yield [activation, i]
104 w_ = (w + 2 * padding - size) // stride + 1
105 h_ = (h + 2 * padding - size) // stride + 1
106 w, h, c = w_, h_, n
107 l = w * h * c
108 #-----------------------------------------------------
109 elif d['type'] == '[maxpool]':
110 stride = d.get('stride', 1)
111 size = d.get('size', stride)
112 padding = d.get('padding', (size-1) // 2)
113 yield ['maxpool', i, size, stride, padding]
114 w_ = (w + 2*padding) // d['stride']
115 h_ = (h + 2*padding) // d['stride']
116 w, h = w_, h_
117 l = w * h * c
118 #-----------------------------------------------------
119 elif d['type'] == '[avgpool]':

Callers 1

parse_cfgMethod · 0.85

Calls 2

parserFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected