{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Virtual Proctoring using Amazon Rekognition\n", "\n", "These notebook provide a walkthrough of some Amazon Rekognition APIs that are relevant to Virtual Proctoring.\n", "\n", "In order to start, it's necessary to create a bucket where to host sample images and videos used by each notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# First, let's get the latest installations of our dependencies\n", "!pip install --upgrade pip\n", "!pip install botocore --upgrade\n", "!pip install boto3 --upgrade\n", "!pip install IPython --upgrade" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Initialize Dependencies\n", "import boto3\n", "import botocore\n", "\n", "# Initialize clients\n", "REGION = boto3.session.Session().region_name\n", "s3 = boto3.client('s3', REGION)\n", "sts = boto3.client(\"sts\")\n", "\n", "# An S3 Bucket is created and then sample images and videos are copied over there\n", "account_id = sts.get_caller_identity()[\"Account\"]\n", "bucket_name = \"amazon-rekognition-code-samples-{}-{}\".format(account_id, REGION)\n", "\n", "try:\n", " s3.head_bucket(Bucket=bucket_name)\n", "except botocore.exceptions.ClientError as e:\n", " error_code = int(e.response['Error']['Code'])\n", " if error_code == 403:\n", " print(\"Private Bucket. Forbidden Access! Please ensure the bucket is accessible from the Notebook\")\n", " elif error_code == 404:\n", " s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={\n", " 'LocationConstraint': REGION\n", " })\n", "\n", "media = ['leaving.mp4', 'objects.mp4', 'cellphone.jpg', 'identity.jpg', 'looking_at_screen.jpg']\n", "\n", "for file in media:\n", " file_name = \"media/{}\".format(file)\n", " with open(file_name, 'rb') as data:\n", " print(\"uploading s3://{}/{}\".format(bucket_name, file_name))\n", " s3.upload_fileobj(data, bucket_name, file_name)\n", "\n", "print(\"All done\")\n", "\n", "%store bucket_name" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now you can proceed with the first lab." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.5" } }, "nbformat": 4, "nbformat_minor": 4 }