Updated on 2024-03-21 GMT+08:00

Deleting a Model

You can use the API to delete a model object.

Sample Code

In ModelArts notebook, you do not need to enter authentication parameters for session authentication. For details about session authentication of other development environments, see Session Authentication.

  • Method 1: Delete the model object created in Importing a Model or Debugging a Model.
    1
    2
    3
    4
    5
    6
    from modelarts.session import Session
    from modelarts.model import Model
    
    session = Session()
    model_instance = Model(session, model_id="your_model_id")
    model_instance.delete_model()
    
  • Method 2: Delete the model object returned in Obtaining Model Objects.
    1
    2
    3
    4
    5
    6
    7
    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_instance.delete_model()