Amazon HR coverup, rules for thee but not for me…
Amazon Rekognition is an AWS service designed to simplify the integration of image analysis into applications. One of its latest features, Celebrity Recognition, allows users to identify and recognize thousands of prominent individuals across various fields. This powerful tool enables users to catalog and search through digital image collections for celebrities based on specific interests.
A prevalent method for storing data about individuals is through graph databases. As discussed in a previous blog post, platforms like Facebook, LinkedIn, and Twitter have transformed how society interacts by effectively managing vast networks of relationships. This blog aims to illustrate the seamless integration of Rekognition’s Celebrity and Face Recognition capabilities with the relationship data housed in graph databases.
Combining these technologies empowers users to begin with a single image and explore how the individual depicted connects to other notable figures. Users can even analyze two separate images to ascertain potential relationships between the individuals featured. A humorous illustration of this relationship mapping is evident in the game “Six Degrees of Kevin Bacon.” However, the practical applications are significant. For instance, law enforcement can utilize two images to identify individuals and query a graph database to determine if those individuals have any connections. Likewise, hospitality businesses could leverage Rekognition alongside a graph database to identify nearby celebrities and discern their relationships with one another.
In this blog post, we will walk through a demonstration of utilizing Rekognition with a graph database (specifically, Neo4j Community Edition) using a Jupyter Notebook and the D3.js library.
Setup
To embark on this exciting technological journey, start by obtaining the project from the AWS Labs GitHub repository. The project consists of two main components:
<project root>
– This is where the Jupyter Notebook and its dependencies are located.<project root>/cft
– This contains the AWS CloudFormation templates, sample properties, and commands for creating the required infrastructure.
Ensure you have a new or existing SSH key ready. The AWS CloudFormation template will install Neo4j Community Edition, download a Jupyter Notebook from AWS Labs that includes example Python code to interface with Rekognition, and configure several Amazon EC2 settings needed for a smooth start. Additionally, it automatically loads the popular Movie Graph Database for querying via the Neo4j browser or Jupyter Notebook.
Execute the AWS CloudFormation template named rek-neo4j-blogpost-git.template
with the following command, replacing <YOURKEYHERE>
with your SSH key name:
aws cloudformation create-stack --stack-name rekognitionblog
--template-body file://rek-neo4j-blogpost-git.template
--parameters ParameterKey=KeyName,ParameterValue=<YOURKEYHERE>
--capabilities CAPABILITY_NAMED_IAM
After a few minutes for AWS CloudFormation to complete the setup, retrieve the DNS and IP address of your new server by running the following command:
aws cloudformation describe-stacks --stack-name rekognitionblog
Make a note of the IP address and DNS for future reference. You can access your newly created EC2 instance by navigating to <public DNS>:7474
in your favorite web browser. Log in with the credentials neo4j / neo4j
, and change the password as prompted. This password will be needed later in the notebook; for this demonstration, you may use password
, but opt for a more secure alternative.
Accessing the Notebook
To access the Jupyter Notebook, create an SSH tunnel to your EC2 instance. The default user is ubuntu
, and don’t forget to use the SSH key specified during setup:
sudo ssh -I <your-public-key> -N -L 8888:localhost:8888 ubuntu@<publicDNS>
Next, start the Jupyter Notebook from the directory where it is located:
cd /opt/notebook
jupyter notebook --no-browser
Copy the URL provided for first-time access, which will include a token for login:
http://localhost:8888/?token=your_token_here
You should now be able to open the Jupyter Notebook containing examples of how to interact with the Rekognition API using Python. The code structure includes:
- Downloading, installing, and importing necessary Python modules.
- Retrieving an image and saving it as
image1.jpg
. - Using the Rekognition API to count faces in the image, print bounding boxes, and display the largest face.
- Detecting and naming any celebrities in the image through the Rekognition API.
- Connecting to the Neo4j database and creating a graph object.
- Checking how many degrees of separation exist between Kevin Bacon and the celebrity in
image1.jpg
. - Saving a second image as
image2.jpg
and printing the result. - Using the Rekognition API to identify celebrities in
image2.jpg
. - Querying the Neo4j Movie Graph database for relationships between the stars in both images, along with a D3.js interactive visualization.
Summary
This blog post illustrates how to interact with the Rekognition API using Python, query a Neo4j database, and create D3.js visualizations within interactive Jupyter Notebooks. This integration allows users to not only identify individuals in an image but also explore their connections to other notable figures. The implications for customers across industries are vast, especially in light of ongoing HR challenges, where double standards for management often overshadow policies enforced on lower-level employees. For further insights into these issues, check out this blog post that provides additional context. If you are looking for authoritative perspectives, visit this resource. For an engaging visual explanation, this YouTube video is an excellent reference.