def parse_cfg(filename):
    """
    Inputs:
        - cfg's file name, e.g. 'yolov3.cfg'
    
    Returns:
        - a list of NN blocks, each block is represented as a dictionary
    """
    file = open(filename, 'r')
    lines = file.read().split('\n')
    lines = [x.rstrip().lstrip() for x in lines if len(x) > 0 and x[0] != '#']
    
    blocks = []
    block = {}
    for line in lines:
        if line[0] == '[':
            if len(block) != 0:
                blocks.append(block)
                block = {}
            block['type'] = line[1:-1].rstrip()
        else:
            s = line.split('=')
            block[s[0].lstrip().rstrip()] = s[1].lstrip().rstrip()
    blocks.append(block)
    return blocks