【发布时间】:2021-04-04 01:28:04
【问题描述】:
我对 AWS 和云环境非常陌生。我是一名机器学习工程师,我计划在 AWS 环境中构建一个自定义 CNN,以预测给定图像是否存在 iPhone。
我做了什么:
第 1 步:
我为 iPhone 分类器创建了一个 S3 存储桶,其文件夹结构如下:
Iphone_Classifier > Train > Yes_iphone_images > 1000 images
> No_iphone_images > 1000 images
> Dev > Yes_iphone_images > 100 images
> No_iphone_images > 100 images
> Test > 30 random images
权限 -> 阻止所有公共访问
第 2 步:
然后我去 Amazon Sagemaker,并创建一个实例:
我选择以下
Name: some-xyz,
Type: ml.t2.medium
IAM : created new IAM role ( root access was enabled.)
others: All others were in default
然后笔记本实例被创建并打开。
第 3 步:
打开实例后,
1. I used to prefer - conda_tensorflow2_p36 as interpreter
2. Created a new Jupyter notebook and stated.
3. I checked image classification examples but was confused, and most others used CSV files, but I want to retrieve images from S3 buckets.
问题:
1. How simply can we access the S3 bucket image dataset from the Jupiter Instances of Sagemaker?
2. I exactly need the reference code to access the S3 bucket images.
3. Is it a good approach to copy the data to the notebook or is it better to work from the S3 bucket.
我尝试过的是:
import boto3
client = boto3.client('s3')
# I tried this one and failed
#path = 's3://iphone/Train/Yes_iphone_images/100.png'
# I tried this one and failed
path = 's3://iphone/Test/10.png'
# I uploaded to the notebook instance an image file and when I try to read it works
#path = 'thiyaga.jpg'
print(path)
import cv2
from matplotlib import pyplot as plt
print(cv2.__version__)
plt.imshow(img)
【问题讨论】:
标签: python amazon-web-services amazon-s3 artificial-intelligence amazon-sagemaker