Skip to content

Instantly share code, notes, and snippets.

@ljbelenky
Last active June 3, 2020 19:12
Show Gist options
  • Save ljbelenky/19a443c73baf60f1797ee27b9d6cf085 to your computer and use it in GitHub Desktop.
Save ljbelenky/19a443c73baf60f1797ee27b9d6cf085 to your computer and use it in GitHub Desktop.
Open image file from s3 bucket
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import boto3
import tempfile
s3 = boto3.resource('s3', region_name='us-west-1', aws_access_key_id=ACCESS_ID, aws_secret_access_key=ACCESS_KEY)
bucket = s3.Bucket('galvanize-capstone')
object = bucket.Object('images_001/images/00000001_000.png')
tmp = tempfile.NamedTemporaryFile()
with open(tmp.name, 'wb') as f:
object.download_fileobj(f)
img=mpimg.imread(tmp.name)
plt.imshow(img)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment