更新时间:2024-01-18 GMT+08:00

解析Manifest文件

解析Manifest文件,支持本地和OBS。如果是OBS,需要Session信息。

manifest.parse_manifest(manifest_path, encoding='utf-8')

示例代码

通过Manifest路径来解析获取Manifest的信息。
from modelarts.session import Session 
from modelarts.dataset.format.manifest import Manifest

path = "obs://your-obs-bucket/manifest/V001.manifest"
session = Session() 
manifest_info= Manifest.parse_manifest(path,session=session)

参数说明

表1 请求参数

参数

是否必选

参数类型

描述

manifest_path

String

Manifest文件路径,支持OBS和本地路径。如果是OBS,需要Session信息。

encoding

String

文件编码格式,默认为utf-8。

表2 manifest_info返回参数说明

参数

参数类型

描述

size

Long

样本数量。

samples

JSON Array

样本列表。样本属性请见表3

表3 sample样本属性

参数

参数类型

描述

source

String

被标注对象的URI,支持OBS、HTTPS、Content。其中Content为文本内容,例如:“source”:“s3://path-to-jpg”,“source”:“content://I love machine learning”。

annotations

JSON Array

样本标注信息。若不给出,则是未标注对象。

annotations值为一个对象列表。标注属性请见表4

usage

String

用途,可选值为TRAIN、EVAL、TEST、INFERENCE。指明该对象用于训练、评估、测试、推理,若没有给出该字段,则使用者自行决定如何使用该对象。

inference_loc

String

当此Manifest文件由推理服务生成时会有该字段,表示推理输出的结果文件位置。

id

String

样本ID。

source_type

String

source的类型,比如csv。

source_property

String

source的属性。

hard

Boolean

是否是难例,true表示是难例,false为非难例。

hard_coefficient

Double

难度系数,范围为[0,1]。

hard_reasons

String

标签级别难例原因。通过中划线间隔单个难例原因ID。

source_map

String

source的映射。

表4 annotation标注属性

参数

参数类型

描述

name

String

标注名称。

type

String

标注类型。

id

String

标注ID。

annotation_loc

String

标注文件的云存储路径,对于物体检测是必选字段,对于其他类型是可选字段。

annotation_property

String

标注属性。

confidence

Double

置信度,数值类型,范围0<=confidence<=1,表示机器标注的置信度。

creation_time

String

创建该标注的时间。是用户写入标注的时间,不是Manifest生成时间。

annotated_by

String

标注人。

annotation_format

String

描述标注文件的格式。默认为“PASCAL VOC”。

hard

Boolean

是否是难例。

hard_coefficient

Double

难度系数。

annotation_loc_map

String

标注文件路径的映射。