In [1]:
import graphlab
In [2]:
image_train = graphlab.SFrame('image_train_data_2/')
In [3]:
image_train.head()
Out[3]:
In [4]:
knn_model = graphlab.nearest_neighbors.create(image_train,
features=['deep_features'],
label='id')
In [5]:
cat = image_train[18:19]
In [6]:
graphlab.canvas.set_target('ipynb')
In [7]:
cat['image'].show()
In [8]:
knn_model.query(cat)
Out[8]:
In [10]:
def get_images_from_ids(query_result):
return image_train.filter_by(query_result['reference_label'],
'id')
In [11]:
cat_neighbors = get_images_from_ids(knn_model.query(cat))
In [12]:
cat_neighbors['image'].show()
In [13]:
car = image_train[8:9]
In [14]:
car['image'].show()
In [15]:
get_images_from_ids(knn_model.query(car))['image'].show()
In [16]:
show_neighbors = lambda i: get_images_from_ids(knn_model.query(image_train[i:i+1]))['image'].show()
In [17]:
show_neighbors(8)
In [18]:
show_neighbors(26)
In [19]:
show_neighbors(122)
In [20]:
show_neighbors(1222)
In [21]:
show_neighbors(2000)
In [23]:
image_train['label'].sketch_summary()
Out[23]:
In [30]:
dog_sframe = image_train[image_train['label'] == 'dog']
In [31]:
dog_sframe.show()
In [32]:
len(dog_sframe)
Out[32]:
In [33]:
cat_sframe = image_train[image_train['label'] == 'cat']
In [34]:
bird_sframe = image_train[image_train['label'] == 'bird']
In [35]:
automobile_sframe = image_train[image_train['label'] == 'automobile']
In [38]:
len(cat_sframe), len(bird_sframe), len(automobile_sframe), len(dog_sframe)
Out[38]:
In [39]:
cat_sframe.show()
In [40]:
dog_sframe.show()
In [41]:
bird_sframe.show()
In [42]:
automobile_sframe.show()