Last active
June 3, 2020 19:12
-
-
Save ljbelenky/19a443c73baf60f1797ee27b9d6cf085 to your computer and use it in GitHub Desktop.
Open image file from s3 bucket
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
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