Skip to content

Commit

Permalink
Add autostart script for serving
Browse files Browse the repository at this point in the history
  • Loading branch information
cxnt committed Dec 3, 2024
1 parent 1587f0b commit 618a15f
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions supervisely_integration/serve/scripts/auto_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,63 @@
from dotenv import load_dotenv

import supervisely as sly
from supervisely.nn.utils import ModelSource, RuntimeType

load_dotenv(os.path.expanduser("~/supervisely.env"))
load_dotenv("local.env")

api: sly.Api = sly.Api.from_env()

task_id = 68843 # <---- Change this to your task_id
task_id = 68910 # <---- Change this to your task_id
method = "deploy_from_api"


data = {"deploy_params": {}}
api.app.send_request(task_id, method, data)
# Pretrained
pretrained_model_data = {
"deploy_params": {
"model_files": {
"config": "rtdetrv2_r18vd_120e_coco.yml",
"checkpoint": "https://github.com/lyuwenyu/storage/releases/download/v0.2/rtdetrv2_r18vd_120e_coco_rerun_48.1.pth",
},
"model_source": ModelSource.PRETRAINED,
"model_info": {
"Model": "RT-DETRv2-L",
"dataset": "COCO",
"AP_val": 53.4,
"Params(M)": 42,
"FPS(T4)": 108,
"meta": {
"task_type": "object detection",
"model_name": "RT-DETRv2-L",
"model_files": {
"checkpoint": "https://github.com/lyuwenyu/storage/releases/download/v0.1/rtdetrv2_r50vd_6x_coco_ema.pth",
"config": "rtdetrv2_r50vd_6x_coco.yml",
},
},
},
"device": "cuda",
"runtime": RuntimeType.PYTORCH,
}
}

# Custom
# @TODO: add deploy_params.json to team files for convenience?
custom_model_data = {
"deploy_params": {
"model_files": {
"config": "/experiments/43192_Apples/68908_RT-DETRv2/model_config.yml",
"checkpoint": "/experiments/43192_Apples/68908_RT-DETRv2/checkpoints/best.pth",
},
"model_source": ModelSource.CUSTOM,
"model_info": {
"artifacts_dir": "/experiments/43192_Apples/68908_RT-DETRv2",
"framework_name": "RT-DETRv2",
"model_name": "RT-DETRv2-S",
"model_meta": "model_meta.json",
},
"device": "cuda",
"runtime": RuntimeType.PYTORCH,
}
}

api.app.send_request(task_id, method, custom_model_data)

0 comments on commit 618a15f

Please sign in to comment.