in sample-apps/custom-model/code/model/model.py [0:0]
def compile_model(self, s3_uri, input_name='input_1', input_shape='224,224,3', framework='TENSORFLOW', device='jetson_xavier'):
"""Compiles a model with Amazon Sagemaker Neo."""
MODEL_INPUT_SHAPE = '{{"{}":[1,{}]}}'.format(input_name,input_shape)
COMPILED_MODEL_FOLDER_URI = 's3://{}/models-compiled'.format(self.bucket_name)
COMPILATION_JOB = 'panorama-custom-model-'+ str(time.time()).split('.')[0]
logger.info('Compiling {}'.format(s3_uri))
response = sagemaker_client.create_compilation_job(
CompilationJobName=COMPILATION_JOB,
RoleArn=self.service_role_arn,
InputConfig={
'S3Uri': s3_uri,
'DataInputConfig': MODEL_INPUT_SHAPE,
'Framework': framework
},
OutputConfig={
'S3OutputLocation': COMPILED_MODEL_FOLDER_URI,
'TargetDevice': device
},
StoppingCondition={
'MaxRuntimeInSeconds': 900
}
)
logger.info(response)
return COMPILATION_JOB