Skip to content

Instantly share code, notes, and snippets.

@kamath
Created December 19, 2018 23:30
Show Gist options
  • Select an option

  • Save kamath/d043642ee9f2a04e1abed63f19fc9564 to your computer and use it in GitHub Desktop.

Select an option

Save kamath/d043642ee9f2a04e1abed63f19fc9564 to your computer and use it in GitHub Desktop.
import PIL as pillow
from PIL import Image
import numpy as np
import os
import pandas as pd
import random
import keras
from matplotlib import pyplot as plt
import numpy as np
%matplotlib inline
from keras import backend as K
from keras.layers import Input,Conv2D,MaxPooling2D,UpSampling2D, Conv2DTranspose
from keras.models import Model
from keras.optimizers import RMSprop
from keras import callbacks
import boto3
from sagemaker import get_execution_role
from s3monkey import S3FS
from io import BytesIO
role = get_execution_role()
client = boto3.client('s3')
s3 = boto3.resource('s3')
bucket = s3.Bucket('beast-images')
def getfile(data_key):
return f's3://beast-images/{data_key}'
def getimage(image):
obj = client.get_object(Bucket='beast-images', Key=image)
return BytesIO(obj['Body'].read())
def openimage(image):
return Image.open(getimage(image))
def listdir(folder):
return list(map(lambda x: x.key, bucket.objects.filter(Delimiter='/', Prefix=f'{folder}/')))[1:]
#openimage('A-Bathing-Ape-Bapesta-DC-Comics-Batman.png')
items = listdir('shoes')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment