Exemplo n.º 1
0
def yolov2(x, num_anchors, num_classes, test=False, feature_dict=None):
    feature_dict_d = {}
    c18 = darknet19_feature(x, test=test, feature_dict=feature_dict_d)
    c13 = feature_dict_d['c13']
    c21 = yolov2_feature(c13, c18, test=test, feature_dict=feature_dict)
    det = yolov2_detection_layer(c21, num_anchors, num_classes)
    if feature_dict is not None:
        feature_dict.update(feature_dict_d)
        feature_dict['c21'] = c21
        feature_dict['det'] = det
    return det
Exemplo n.º 2
0
def main():
    args = get_args()

    # Defining network first
    x = nn.Variable((1, 3, 224, 224))
    y = darknet19.darknet19_feature(x / 255, test=True)

    # Get NNabla parameters
    params = nn.get_parameters(grad_only=False)

    # Parse Darknet weights and store them into NNabla params
    dn_weights = parser.load_weights_raw(args.input)
    cursor = 0
    for i in range(1, 19):  # 1 to 18
        print("Layer", i)
        cursor = parser.load_convolutional_and_get_next_cursor(
            dn_weights, cursor, params, 'c{}'.format(i))

    nn.save_parameters(args.output)