我使用 AWS SageMaker 训练了一个 MobileNet v1 SSD 模型,它训练得很好。我有一个 export/Servo/xxx/saved_graph(从检查点派生的 tflite 模型在物联网设备上完美运行。)在 SageMaker 上部署的模型作为端点没有问题。我的问题是,我不知道如何将图像输入模型端点。(这大概与询问如何将数据输入服务模型相同?)
当我查询模型(如下)时,我看到输入签名是“serialized_example”。所以,我假设我需要一个序列化的例子。这就是我缺乏天赋的地方。
我需要帮助了解如何将 jpg 文件转换为序列化示例。或者我如何使用 tfrecord。
saved_model_cli show --dir {MODEL_PATH} --tag_set serve --signature_def tensorflow/serving/predict
产量(我省略了输出):
inputs['serialized_example'] tensor_info:
dtype: DT_STRING
shape: ()
name: tf_example:0
我有一个数据集,但不知道如何获得正确的课程 -
raw_dataset = tf.data.TFRecordDataset(tfrecord_file_list)
example_decoder = TfExampleDecoder()
decoded_dataset = raw_dataset.map(example_decoder.decode)
如果我枚举解码的数据集,我如何将数据输入我的模型?
for n, e in enumerate(decoded_dataset.take(4)):
what do I do with e - which looks like:
<DatasetV1Adapter shapes: {image: (?, ?, 3), source_id: (), key: (), filename: (), groundtruth_boxes: (?, 4), groundtruth_area: (?,), groundtruth_is_crowd: (?,), groundtruth_difficult: (?,), groundtruth_group_of: (?,), groundtruth_weights: (?,), groundtruth_classes: (?,), groundtruth_image_classes: (?,), original_image_spatial_shape: (2,)}, types: {image: tf.uint8, source_id: tf.string, key: tf.string, filename: tf.string, groundtruth_boxes: tf.float32, groundtruth_area: tf.float32, groundtruth_is_crowd: tf.bool, groundtruth_difficult: tf.int64, groundtruth_group_of: tf.int64, groundtruth_weights: tf.float32, groundtruth_classes: tf.int64, groundtruth_image_classes: tf.int64, original_image_spatial_shape: tf.int32}>