In [3]:
%load_ext autoreload
%autoreload 2
from IPython.display import HTML
import vislab.datasets
import aphrodite.results
import os
import pandas as pd
In [21]:
def top_k_for_styles(df, filter_ind, sort_columns, k=5):
return HTML(' '.join(
'<h4>{}</h4>'.format(sort_column) + ' '.join(
'<img src="{}" width="210px" />'.format(x)
for x in df[filter_ind].sort('pred_style_' + sort_column, ascending=False)['image_url'].iloc[:k]
)
for sort_column in sort_columns
))
In [4]:
def top_k_images(df, k=10):
return HTML(' '.join('<img src="{}" width="210px" />'.format(x) for x in df['image_url'].iloc[:k]))
In [42]:
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')
pred_df = pred_df[[x for x in pred_df.columns if x.startswith('pred_style_')]]
wp_df = vislab.datasets.wikipaintings.get_df()
wp_df = wp_df.join(vislab.datasets.wikipaintings.get_style_df())
df = pred_df.join(wp_df)
In [43]:
top_k_for_styles(
df, [True] * df.shape[0],
['HDR', 'Bright,_Energetic', 'Ethereal', 'Horror', 'Serene', 'Macro', 'Minimal', 'Geometric_Composition', 'Sunny', 'Noir', 'Romantic', 'Soft,_Pastel', 'Vintage'], k=10)
Out[43]:
In [33]:
results_df, preds_panel = aphrodite.results.load_pred_results(
'wp_on_flickr_oct30', os.path.expanduser('~/work/aphrodite/data/results2'),
multiclass=True, force=False)
pred_df = preds_panel.minor_xs('decaf_fc6 False vw')
pred_df = pred_df[[x for x in pred_df.columns if x.startswith('pred_')]]
pred_df = pred_df[[x for x in pred_df.columns if x.startswith('pred_')]]
flickr_df = vislab.datasets.flickr.load_flickr_df()
df2 = flickr_df.join(pred_df)
In [40]:
top_k_for_styles(
df2, [True] * df.shape[0],
['Abstract_Art', 'Abstract_Expressionism', 'Neoclassicism', 'Color_Field_Painting', 'Cubism',
'Early_Renaissance', 'High_Renaissance', 'Impressionism', 'Minimalism', 'Surrealism', 'Realism', 'Rococo', 'Pop_Art'], k=10)
Out[40]: