<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Building an image retrieval system with deep features
Fire up GraphLab Create
Step1:  Load the CIFAR-10 dataset
We will use a popular benchmark dataset in computer vision called CIFAR-10.  
(We've reduced the data to just 4 categories = {'cat','bird','automobile','dog'}.)
This dataset is already split into a training set and test set. In this simple retrieval example, there is no notion of "testing", so we will only use the training data.
Step2:  Computing deep features for our images
The two lines below allow us to compute deep features.  This computation takes a little while, so we have already computed them and saved the results as a column in the data you loaded. 
(Note that if you would like to compute such deep features and have a GPU on your machine, you should use the GPU enabled GraphLab Create, which will be significantly faster for this task.)
Step3:  Train a nearest-neighbors model for retrieving images using deep features
We will now build a simple image retrieval system that finds the nearest neighbors for any image.
Step4:  Use image retrieval model with deep features to find similar images
Let's find similar images to this cat picture.
Step5:  We are going to create a simple function to view the nearest neighbors to save typing
Step6:  Very cool results showing similar cats.
Finding similar images to a car
Step7:  Just for fun, let's create a lambda to find and show nearest neighbor images
<ASSISTANT_TASK:>
Python Code:
import graphlab
Explanation: Building an image retrieval system with deep features
Fire up GraphLab Create
End of explanation
image_train = graphlab.SFrame('image_train_data/')
Explanation: Load the CIFAR-10 dataset
We will use a popular benchmark dataset in computer vision called CIFAR-10.  
(We've reduced the data to just 4 categories = {'cat','bird','automobile','dog'}.)
This dataset is already split into a training set and test set. In this simple retrieval example, there is no notion of "testing", so we will only use the training data.
End of explanation
# deep_learning_model = graphlab.load_model('http://s3.amazonaws.com/GraphLab-Datasets/deeplearning/imagenet_model_iter45')
# image_train['deep_features'] = deep_learning_model.extract_features(image_train)
image_train.head()
Explanation: Computing deep features for our images
The two lines below allow us to compute deep features.  This computation takes a little while, so we have already computed them and saved the results as a column in the data you loaded. 
(Note that if you would like to compute such deep features and have a GPU on your machine, you should use the GPU enabled GraphLab Create, which will be significantly faster for this task.)
End of explanation
knn_model = graphlab.nearest_neighbors.create(image_train,
                                              features=['deep_features'],
                                              label='id')
Explanation: Train a nearest-neighbors model for retrieving images using deep features
We will now build a simple image retrieval system that finds the nearest neighbors for any image.
End of explanation
graphlab.canvas.set_target('ipynb')
cat = image_train[18:19]
cat['image'].show()
knn_model.query(cat)
Explanation: Use image retrieval model with deep features to find similar images
Let's find similar images to this cat picture.
End of explanation
def get_images_from_ids(query_result):
    return image_train.filter_by(query_result['reference_label'],'id')
cat_neighbors = get_images_from_ids(knn_model.query(cat))
cat_neighbors['image'].show()
Explanation: We are going to create a simple function to view the nearest neighbors to save typing:
End of explanation
car = image_train[8:9]
car['image'].show()
get_images_from_ids(knn_model.query(car))['image'].show()
Explanation: Very cool results showing similar cats.
Finding similar images to a car
End of explanation
show_neighbors = lambda i: get_images_from_ids(knn_model.query(image_train[i:i+1]))['image'].show()
show_neighbors(8)
show_neighbors(26)
Explanation: Just for fun, let's create a lambda to find and show nearest neighbor images
End of explanation
<END_TASK>