()
return jsonify(output[0])
Trigger a visualization via the REST API

    Takes a single image and generates the visualization data, returning the
    output exactly as given by the target visualization.
Trigger a visualization via the REST API
Trigger a visualization via the REST API
def visualize():
    """Trigger a visualization via the REST API

    Takes a single image and generates the visualization data, returning the
    output exactly as given by the target visualization.

    """

    session['settings'] = {}
    image_uid = request.args.get('image')
    vis_name = request.args.get('visualizer')
    vis = get_visualizations()[vis_name]
    if vis.ALLOWED_SETTINGS:
        for key in vis.ALLOWED_SETTINGS.keys():
            if request.args.get(key) is not None:
                session['settings'][key] = request.args.get(key)
            else:
                session['settings'][key] = vis.ALLOWED_SETTINGS[key][0]
    else:
        logger.debug('Selected Visualizer {0} has no settings.'.format(vis_name))
    inputs = []
    for image in session['image_list']:
        if image['uid'] == int(image_uid):
            full_path = os.path.join(session['img_input_dir'],
                                     image['filename'])
            entry = dict()
            entry['filename'] = image['filename']
            entry['data'] = Image.open(full_path)
            inputs.append(entry)

    vis.update_settings(session['settings'])
    output = vis.make_visualization(
        inputs, output_dir=session['img_output_dir'])
    return jsonify(output[0])
def visualize ( ) : session [ 'settings' ] = { } image_uid = request . args . get ( 'image' ) vis_name = request . args . get ( 'visualizer' ) vis = get_visualizations ( ) [ vis_name ] if vis . ALLOWED_SETTINGS : for key in vis . ALLOWED_SETTINGS . keys ( ) : if request . args . get ( key ) is not None : session [ 'settings' ] [ key ] = request . args . get ( key ) else : session [ 'settings' ] [ key ] = vis . ALLOWED_SETTINGS [ key ] [ 0 ] else : logger . debug ( 'Selected Visualizer {0} has no settings.' . format ( vis_name ) ) inputs = [ ] for image in session [ 'image_list' ] : if image [ 'uid' ] == int ( image_uid ) : full_path = os . path . join ( session [ 'img_input_dir' ] , image [ 'filename' ] ) entry = dict ( ) entry [ 'filename' ] = image [ 'filename' ] entry [ 'data' ] = Image . open ( full_path ) inputs . append ( entry ) vis . update_settings ( session [ 'settings' ] ) output = vis . make_visualization ( inputs , output_dir = session [ 'img_output_dir' ] ) return jsonify ( output [ 0 ] )