Forked from trevormunoz/rekognition-labels-analysis.ipynb
Created
July 20, 2018 19:13
-
-
Save edsu/ef9a76a6f352e5bf78b6c0878d35705a to your computer and use it in GitHub Desktop.
Quick test of Amazon rekognition output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import json\n", | |
| "import pandas \n", | |
| "from random import randrange\n", | |
| "from IPython.core.display import Image, display" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "DATAFILE = 'notebook_data.json'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "with open(DATAFILE, 'r') as infile:\n", | |
| " LABELS = json.loads(infile.read())" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "['Abies',\n", | |
| " 'Acanthaceae',\n", | |
| " 'Accessories',\n", | |
| " 'Adapter',\n", | |
| " 'Adorable',\n", | |
| " 'Adventure',\n", | |
| " 'Aerial View',\n", | |
| " 'Affenpinscher',\n", | |
| " 'Afro Hairstyle',\n", | |
| " 'Agavaceae',\n", | |
| " 'Aircraft',\n", | |
| " 'Aircraft Carrier',\n", | |
| " 'Airedale',\n", | |
| " 'Airfield',\n", | |
| " 'Airmail',\n", | |
| " 'Airplane',\n", | |
| " 'Airport',\n", | |
| " 'Aisle',\n", | |
| " 'Alcohol',\n", | |
| " 'Algae']" | |
| ] | |
| }, | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "sorted(LABELS.keys())[:20]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "432" | |
| ] | |
| }, | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "len(LABELS['Document'])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 11, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "def get_rand_image(key):\n", | |
| " return LABELS[key][randrange(0, (len(LABELS[key])))]['image']\n", | |
| "\n", | |
| "def display_image(img): \n", | |
| " url = 'https://s3.amazonaws.com/{0}'.format(img)\n", | |
| " print(url)\n", | |
| " display(Image(url, width=800, unconfined=True))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "https://s3.amazonaws.com/mith-lakeland-media/0007.jpg\n" | |
| ] | |
| }, | |
| { | |
| "data": { |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment