This file contains 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
import io | |
from PIL import Image # https://pillow.readthedocs.io/en/4.3.x/ | |
import requests # http://docs.python-requests.org/en/master/ | |
# example image url: https://m.media-amazon.com/images/S/aplus-media/vc/6a9569ab-cb8e-46d9-8aea-a7022e58c74a.jpg | |
def download_image(url, image_file_path): | |
r = requests.get(url, timeout=4.0) | |
if r.status_code != requests.codes.ok: |
This file contains 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
# | |
# written for Amazon Linux AMI | |
# creates an AWS Lambda deployment package for pytorch deep learning models (Python 3.6.1) | |
# assumes lambda function defined in ~/main.py | |
# deployment package created at ~/waya-ai-lambda.zip | |
# | |
# | |
# install python 3.6.1 | |
# |
This file contains 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
import io | |
import boto3 | |
import PIL.Image | |
import torch | |
from torch.utils import model_zoo | |
import torchvision | |
s3_client = boto3.client('s3') |
This file contains 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
import collections | |
import json | |
def duplicates(): | |
# | |
# organize raw Rekognition `boto3.client('rekognition').get_face_search()` response for debugging this issue | |
# | |
with open('duplicated_index_bug.json', 'r') as f: # https://s3.us-east-2.amazonaws.com/brayniac-waya-ai/duplicated_index_bug.json |
This file contains 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
import collections | |
def sort_raw_rekognition_results(results): | |
indices = collections.defaultdict(list) # unique people detected in video to a `list` of their `PersonMatch` objects | |
timestamps = collections.defaultdict(list) # `lists` maintain order so we can keep track of people and their indices | |
timestamps_indices = collections.defaultdict(list) | |
for p in self.results['Persons']: |
This file contains 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
<script src="https://unpkg.com/uport-connect/dist/uport-connect.min.js"></script> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<script type="text/javascript"> | |
function uport() { | |
try { | |
const u = new window.uportconnect.Connect('blockimmo', { | |
clientId: '2ohEPzgzsh7gm68BUcHQMkfaQs8BA4ysatY', | |
network: 'rinkeby', |
This file contains 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
ec2_client = boto3.client('ec2') | |
user_data = """#!/bin/bash | |
sudo apt-get update | |
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" | |
sudo python3 get-pip.py | |
sudo pip3 install boto3 | |
sudo apt-get install -y libgtk2.0-dev | |
sudo pip3 install opencv-python | |
echo "{}" >> {} |
OlderNewer