简体   繁体   English

Sagemaker:指定自定义入口点会导致未找到错误

[英]Sagemaker: Specifying custom entry point gives not found error

I am trying to deploy my object detection model that was trained using tensorflow to sagemaker.我正在尝试将使用 tensorflow 训练的对象检测模型部署到 sagemaker。 I was able to deploy it without specifying any entry points during model creation but it turns out doing that will only work for small sizes images (Sagemaker has limit of 5MB).我能够在模型创建期间不指定任何入口点的情况下部署它,但事实证明这样做仅适用于小尺寸图像(Sagemaker 的限制为 5MB)。 The code I used for this is as:我为此使用的代码是:

from sagemaker.tensorflow.serving import Model

# Initialize model ...
model = Model(
    model_data= s3_path_for_model,
    role=sagemaker_role,
    framework_version="1.14",
    env=env)

# Deploy model ...
predictor = model.deploy(initial_instance_count=1,
                         instance_type='ml.t2.medium')


# Test using an image ...
import cv2
import numpy as np

image_content = cv2.imread("PATH_TO_IMAGE",
                           1).astype('uint8').tolist()
body = {"instances": [{"inputs": image_content}]}

# Works fine for small images ...
# I get predictions perfectly with this ...
results = predictor.predict(body)

So, I googled around and found that I need to pass an entry_point for Model() in order to predict for larger images.所以,我搜索了一下,发现我需要为Model()传递一个entry_point以预测更大的图像。 Something like:就像是:

model = Model(
        entry_point="inference.py",
        dependencies=["requirements.txt"],
        model_data=  s3_path_for_model,
        role=sagemaker_role,
        framework_version="1.14",
        env=env
)

But doing this gives FileNotFoundError: [Errno 2] No such file or directory: 'inference.py' .但是这样做会导致 FileNotFoundError: [Errno 2] No such file or directory: 'inference.py' A little help here please.请在这里提供一些帮助。 I am using sagemaker-python-sdk .我正在使用sagemaker-python-sdk My folder structure is as:我的文件夹结构如下:

model
    |__ 001
          |__saved_model.pb
          |__variables
                |__<contents here>

    |__ code
          |__inference.py
          |__requirements.txt

Note: I have also tried, ./code/inference.py and /code/inference.py.注意:我也试过,./code/inference.py 和 /code/inference.py。

5MB is a hard limit for real-time endpoints. 5MB 是实时端点的硬限制。

Are you sure you need to pass such large images for prediction?您确定需要传递如此大的图像进行预测吗? Most use cases work fine with smaller, lower resolution images.大多数用例适用于较小、较低分辨率的图像。

If you need real-time prediction, one workaround would be to pass the image S3 URI in the prediction request (instead of the image itself), and load the image from S3.如果您需要实时预测,一种解决方法是在预测请求中传递图像 S3 URI(而不是图像本身),然后从 S3 加载图像。

If you don't need real-time prediction, you should look at batch transform, which doesn't enforce that size restriction: https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform.html如果您不需要实时预测,您应该查看批量转换,它不强制执行该大小限制: https : //docs.aws.amazon.com/sagemaker/latest/dg/batch-transform.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows 7嵌入式上运行一个简单的python应用程序会出现“未找到入口点错误”和“加载dll时出错” - Running a simple python app on Windows 7 embedded gives an “Entry point not found error” and an “Error loading dll” entry_point 脚本存储在自定义 Sagemaker Framework 培训作业容器中的什么位置? - Where does entry_point script is stored in custom Sagemaker Framework training job container? 子目录中的 AWS SageMaker SKLearn 入口点? - AWS SageMaker SKLearn entry point in a subdirectory? 在 sagemaker 中使用 XGBoost 作为框架的 entry_point 文件 - entry_point file using XGBoost as a framework in sagemaker AWS Sagemaker SKlearn 入口点允许多个脚本 - AWS Sagemaker SKlearn entry point allow multiple script 更新 anaconda 失败 - 未找到入口点 - Update anaconda failed - Entry point not found 未找到 Python 入口点“console_scripts” - Python Entry point 'console_scripts' not found 指定 windows 路径时找不到文件错误 - File not found error while specifying windows path Docker入口点启动脚本exec错误 - Docker entry point startup script exec error Prophet CMDStanpy 错误 - 未找到过程入口点 - Prophet CMDStanpy error - Procedure Entry Point Not Located
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM