AI开发平台MODELARTS-查询模型详情:示例代码

时间:2024-09-07 09:06:00

示例代码

在ModelArts notebook平台,Session鉴权无需输入鉴权参数。其它平台的Session鉴权请参见Session鉴权

  • 方式1:根据导入模型生成的模型对象进行模型详情查询
    1
    2
    3
    4
    5
    6
    7
    from modelarts.session import Session
    from modelarts.model import Model
    
    session = Session()
    model_instance = Model(session, model_id="your_model_id")
    model_info = model_instance.get_model_info()
    print(model_info)
    
  • 方式2:根据查询模型对象列表返回的模型对象进行模型详情查询
    1
    2
    3
    4
    5
    6
    7
    8
    from modelarts.session import Session
    from modelarts.model import Model
    
    session = Session()
    model_object_list = Model.get_model_object_list(session)
    model_instance = model_object_list[0]                
    model_info = model_instance.get_model_info()
    print(model_info)
    
support.huaweicloud.com/sdkreference-modelarts/modelarts_04_0197.html