ModelInstance (APIObject)
__init__(self, project_id, trial_no, trial_type, model_id, model_name=None)
special
待部署的模型实例
| Parameters: |
|
|---|
Source code in deepwisdom/models/model.py
def __init__(
self,
project_id,
trial_no,
trial_type,
model_id,
model_name=None
):
"""
待部署的模型实例
Args:
project_id (int): 项目id
trial_no (int): 实验id
trial_type (int): 实验类型
model_id (int): 模型id
model_name (str): 模型名称
"""
self.project_id = project_id
self.trial_no = trial_no
self.trial_type = trial_type
self.model_id = model_id
self.model_name = model_name
download_model(self, dir_path=None)
下载模型文件到指定的目录, 默认~/deepwisdom/models。 目前支持表格类下载
| Parameters: |
|
|---|
Source code in deepwisdom/models/model.py
def download_model(self, dir_path=None):
"""
下载模型文件到指定的目录, 默认~/deepwisdom/models。 目前支持表格类下载
Args:
dir_path (string): 自定义目录路径
Returns:
"""
data = {
"model_id": self.model_id
}
server_data = self._server_data(API_URL.MODEL_DOWNLOAD, data)
if dir_path is None:
dir_path = _get_models_dir()
file_list = server_data["model_files"]
for file_obj in file_list:
if "is_dir" in file_obj and file_obj["is_dir"] is True:
continue
r = requests.get(file_obj["file_url"], stream=True)
file_path = _get__model_file(dir_path, file_obj["file_name"].split("/")[-1])
with open(file_path, "wb") as f:
for chunk in r.iter_content(chunk_size=1024): # 1024 bytes
if chunk:
f.write(chunk)