概述
浦源內容平臺-模型中心的Python SDK旨在為開發人員提供編程方式來管理和操作模型中心平臺的功能,以便他們可以輕松地與模型中心進行交互和模型管理。通過Python SDK提供的推理接口,開發人員能夠高效地調用不同的模型,實現模型應用的開發。通過Python SDK,開發人員可以通過編程方式執行以下任務:
- 模型庫的管理:創建模型庫、上傳更新、刪除、查詢模型列表和列出模型的信息
- 元數據管理:SDK應該提供一組API,用于管理模型的元數據,包括模型名稱、評測結果、標簽、作者等信息。
- 訪問控制:SDK應該提供一組API,用于管理模型的訪問控制,包括授權、身份驗證和權限控制。
- 集成和擴展:集成模型中心的模型到自己的工作流中,進行模型推理,應用制作等
使用模型管理平臺的Python SDK,開發人員可以更輕松地管理機器學習模型,并提高開發人員的工作效率。
安裝
pip install openxlab
SDK的鑒權
import openxlab
openxlab.login(ak=<Access Key>, sk=<Secrete Key>)
ak,sk可以從OpenXLab賬號與安全->密鑰管理
頁面獲取
常用操作
模型初始化
from openxlab.model import init
init(path='/home/xlab-app-center')
創建模型倉庫
from openxlab.model import create
create(model_repo='username/model_repo_name',private=True)
上傳模型
from openxlab.model import upload
upload(model_repo='username/model_repo_name',file_type='metafile',source="/path/to/local/folder/metafile.yaml")
metafile.yaml修改
# A simple example of model metadata.
Collections: # Information about the algorithm.- Name: algorithm name # Required. Example: the name of the algorithm, e.g Faster_RCNN.License: apache-2.0 # Required. Example: apache-2.0.Code:URL: GitHub algorithm repository # Required. Links to GitHub algorithm repository code snippet.Version: {version} Frameworks: {frameworks} Models: # A list of Model dicts.
- Name: 模型文件1的文件名 # Required. the name of the model.Results: # A list of Result dicts. Result is a dict capturing the evaluation results of the model. - Task: 任務名 # Required. Name of the task.Dataset: 數據集名,沒有就寫none # Required. Name of the dataset.Weights: 模型文件路徑 # Required. link to download the pretrained weights- Name: 模型文件2的文件名 # Required. the name of the model.Results: # A list of Result dicts. Result is a dict capturing the evaluation results of the model. - Task: 任務名 # Required. Name of the task.Dataset: 數據集名,沒有就寫none # Required. Name of the dataset.Weights: 模型文件路徑 # Required. link to download the pretrained weights
有多少個模型文件就在末尾增加多少個
- Name: 模型文件名 # Required. the name of the model.Results: # A list of Result dicts. Result is a dict capturing the evaluation results of the model. - Task: 任務名 # Required. Name of the task.Dataset: 數據集名,沒有就寫none # Required. Name of the dataset.Weights: 模型文件路徑 # Required. link to download the pretrained weights