{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%load_ext autoreload\n", "%autoreload 2\n", "from IPython.display import HTML\n", "import vislab.datasets\n", "import aphrodite.results\n", "import os\n", "import pandas as pd" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The autoreload extension is already loaded. To reload it, use:\n", " %reload_ext autoreload\n" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "def top_k_for_styles(df, filter_ind, sort_columns, k=5):\n", " return HTML(' '.join(\n", " '

{}

'.format(sort_column) + ' '.join(\n", " ''.format(x)\n", " for x in df[filter_ind].sort('pred_style_' + sort_column, ascending=False)['image_url'].iloc[:k]\n", " )\n", " for sort_column in sort_columns\n", " ))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 21 }, { "cell_type": "code", "collapsed": false, "input": [ "def top_k_images(df, k=10):\n", " return HTML(' '.join(''.format(x) for x in df['image_url'].iloc[:k]))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Flickr styles applied to Wikipaintings" ] }, { "cell_type": "code", "collapsed": false, "input": [ "pred_df = pd.read_hdf(\"../data/results/data_wikipaintings_style_ALL_features_['decaf_fc6']_num_test_16492_num_train_49475_num_val_16492_quadratic_False_task_clf_FROM_FLICKR.h5\", 'df')\n", "pred_df = pred_df[[x for x in pred_df.columns if x.startswith('pred_style_')]]\n", "wp_df = vislab.datasets.wikipaintings.get_df()\n", "wp_df = wp_df.join(vislab.datasets.wikipaintings.get_style_df())\n", "df = pred_df.join(wp_df)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 42 }, { "cell_type": "code", "collapsed": false, "input": [ "top_k_for_styles(\n", " df, [True] * df.shape[0],\n", " ['HDR', 'Bright,_Energetic', 'Ethereal', 'Horror', 'Serene', 'Macro', 'Minimal', 'Geometric_Composition', 'Sunny', 'Noir', 'Romantic', 'Soft,_Pastel', 'Vintage'], k=10)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "

HDR

Bright,_Energetic

Ethereal

Horror

Serene

Macro

Minimal

Geometric_Composition

Sunny

Noir

Romantic

Soft,_Pastel

Vintage

" ], "metadata": {}, "output_type": "pyout", "prompt_number": 43, "text": [ "" ] } ], "prompt_number": 43 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Wikipaintings styles applied to Flickr" ] }, { "cell_type": "code", "collapsed": false, "input": [ "results_df, preds_panel = aphrodite.results.load_pred_results(\n", " 'wp_on_flickr_oct30', os.path.expanduser('~/work/aphrodite/data/results2'),\n", " multiclass=True, force=False)\n", "pred_df = preds_panel.minor_xs('decaf_fc6 False vw')\n", "pred_df = pred_df[[x for x in pred_df.columns if x.startswith('pred_')]]\n", "pred_df = pred_df[[x for x in pred_df.columns if x.startswith('pred_')]]\n", "\n", "flickr_df = vislab.datasets.flickr.load_flickr_df()\n", "df2 = flickr_df.join(pred_df)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Loaded from cache: 1 records\n" ] } ], "prompt_number": 33 }, { "cell_type": "code", "collapsed": false, "input": [ "top_k_for_styles(\n", " df2, [True] * df.shape[0],\n", " ['Abstract_Art', 'Abstract_Expressionism', 'Neoclassicism', 'Color_Field_Painting', 'Cubism',\n", " 'Early_Renaissance', 'High_Renaissance', 'Impressionism', 'Minimalism', 'Surrealism', 'Realism', 'Rococo', 'Pop_Art'], k=10)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "

Abstract_Art

Abstract_Expressionism

Neoclassicism

Color_Field_Painting

Cubism

Early_Renaissance

High_Renaissance

Impressionism

Minimalism

Surrealism

Realism

Rococo

Pop_Art

" ], "metadata": {}, "output_type": "pyout", "prompt_number": 40, "text": [ "" ] } ], "prompt_number": 40 } ], "metadata": {} } ] }