fromgoogle.cloudimportaiplatformdefdelete_model_sample(model_id:str,project:str,location:str):
"""
DeleteaModelresource.Args:model_id:TheIDofthemodeltodelete.Parentresourcenameofthemodelisalsoaccepted.project:Theproject.location:Theregionname.ReturnsNone.
"""
# Initialize the client.aiplatform.init(project=project,location=location)# Get the model with the ID 'model_id'. The parent_name of Model resource can be also# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model=aiplatform.Model(model_name=model_id)# Delete the model.model.delete()
删除模型版本
控制台
从 Google Cloud 控制台的 Vertex AI 部分,进入 Model Registry 页面。
fromgoogle.cloudimportaiplatformdefdelete_model_version_sample(model_id:str,version_id:str,project:str,location:str):
"""
DeleteaModelversion.Args:model_id:TheIDofthemodeltodelete.Parentresourcenameofthemodelisalsoaccepted.version_id:TheversionIDorversionaliasofthemodeltodelete.project:TheprojectID.location:Theregionname.ReturnsNone.
"""
# Initialize the client.aiplatform.init(project=project,location=location)# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry=aiplatform.models.ModelRegistry(model=model_id)# Delete the model version with the version 'version'.model_registry.delete_version(version=version_id)
fromtypingimportListfromgoogle.cloudimportaiplatformdefdelete_aliases_model_version_sample(model_id:str,version_aliases:List[str],version_id:str,project:str,location:str,):
"""
Deletealiasestoamodelversion.Args:model_id:TheIDofthemodel.version_aliases:Theversionaliasestoassign.version_id:TheversionIDofthemodeltoassignthealiasesto.project:TheprojectID.location:Theregionname.ReturnsNone.
"""
# Initialize the client.aiplatform.init(project=project,location=location)# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry=aiplatform.models.ModelRegistry(model=model_id)# Remove the version aliases to the model version with the version 'version'.model_registry.remove_version_aliases(target_aliases=version_aliases,version=version_id)
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-11-21。"],[],[]]