Exemplo n.º 1
0
def vis_overview(img_id):
    '''
    Overview visualization of top activations for each layer w.r.t. a particular image

    # Args
        img_id: Name of image
    '''
    num_maxes = int(request.args.get('num_maxes', '5'))
    tree = get_vis_tree(net_id, img_id)
    layers = [
        dict(layer) for layer in tree.config['layers'].itervalues()
        if layer['include_in_overview']
    ]
    layers.sort(key=lambda l: -l['idx'])
    for layer in layers:
        blob_name = layer['blob_name']
        max_act_ids = get_vis_tree(net_id,
                                   img_id).max_blob_idxs(blob_name)[:num_maxes]
        max_acts = []
        for act_id in max_act_ids:
            path = [(blob_name, act_id)]
            max_acts.append({'act_id': act_id, 'path_id': get_path_id(path)})
        layer['max_acts'] = max_acts
    return render_template('overview.html',
                           layers=layers,
                           imgs_per_row=5,
                           img_id=img_id)
Exemplo n.º 2
0
def json_tree_children(img_id):
    '''
    Retrieve the info of a node's children.

    # Args
        img_id: Name of image
    '''
    path_id = request.args.get('path_id', None)
    path = get_path(path_id)
    tree = get_vis_tree(net_id, img_id)
    children = tree.children_from_path(path)
    for child in children:
        child['path_id'] = get_path_id(child['path'])
    return jsonify({'children': children})
Exemplo n.º 3
0
def json_tree_children(img_id):
    '''
    Retrieve the info of a node's children.

    # Args
        img_id: Name of image
    '''
    path_id = request.args.get('path_id', None)
    path = get_path(path_id)
    tree = get_vis_tree(net_id, img_id)
    children = tree.children_from_path(path)
    for child in children:
        child['path_id'] = get_path_id(child['path'])
    return jsonify({'children': children})
Exemplo n.º 4
0
def vis(img_id):
    '''
    Detailed vis page for a particular net, image, and neuron

    # Args
        img_id: Name of image
    '''
    blob_name = request.args.get('blob_name', '')
    act_id = int(request.args.get('act_id', ''))
    root_path = [(blob_name, act_id)]
    root_id = get_path_id(root_path)
    return render_template('vis.html',
                           root_path_id=root_id,
                           img_id=img_id,
                           root_blob_name=blob_name,
                           root_act_id=act_id)
Exemplo n.º 5
0
def vis(img_id):
    '''
    Detailed vis page for a particular net, image, and neuron

    # Args
        img_id: Name of image
    '''
    blob_name = request.args.get('blob_name', '')
    act_id = int(request.args.get('act_id', ''))
    root_path = [(blob_name, act_id)]
    root_id = get_path_id(root_path)
    return render_template('vis.html',
                           root_path_id=root_id,
                           img_id=img_id,
                           root_blob_name=blob_name,
                           root_act_id=act_id)
Exemplo n.º 6
0
def vis_overview(img_id):
    '''
    Overview visualization of top activations for each layer w.r.t. a particular image

    # Args
        img_id: Name of image
    '''
    num_maxes = int(request.args.get('num_maxes', '5'))
    tree = get_vis_tree(net_id, img_id)
    layers = [dict(layer) for layer in tree.config['layers'].itervalues() if layer['include_in_overview']]
    layers.sort(key=lambda l: -l['idx'])
    for layer in layers:
        blob_name = layer['blob_name']
        max_act_ids = get_vis_tree(net_id, img_id).max_blob_idxs(blob_name)[:num_maxes]
        max_acts = []
        for act_id in max_act_ids:
            path = [(blob_name, act_id)]
            max_acts.append({'act_id': act_id, 'path_id': get_path_id(path)})
        layer['max_acts'] = max_acts
    return render_template('overview.html', layers=layers, imgs_per_row=5, img_id=img_id)