keshav
keshav

Reputation: 146

How to read AWS S3 images from Sagemaker for processing

I have around 10000 images in my S3 bucket. I need to cut each of these images to 12 smaller images and save them in another folder in the S3 bucket. I want to do this through the AWS Sagemaker. I am not able to read the image from the S3 bucket from my Sagemaker Jupter notebook. I have the code for cutting the images.

Need help in reading images and storing them back into S3 from Sagemaker.Is it possible to do this, and also efficiently?

Upvotes: 0

Views: 947

Answers (1)

Olivier Cruchant
Olivier Cruchant

Reputation: 4037

You can bring images to a local repo of your SageMaker instance (eg /home/ec2-user/SageMaker/Pics/ with the following command:

aws s3 sync s3://pic_folder_in_s3 /home/ec2-user/SageMaker/Pics

or in python:

import subprocess as sb

sb.call('aws s3 sync s3://pic_folder_in_s3 /home/ec2-user/SageMaker/Pics'.split())

Note that in order for the transfer to happen, the role carried by your SageMaker instance must have the right to read from this S3 location

Upvotes: 1

Related Questions