Skip to content

Commit

Permalink
SDK to 6.73.242. CheckpointInfo (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev authored Nov 29, 2024
1 parent 338d9f7 commit 53c1eea
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
supervisely==6.73.229
supervisely==6.73.242

openmim
ffmpeg-python==0.2.0
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ RUN mkdir -p /tmp/mmseg \
&& wget https://github.com/open-mmlab/mmsegmentation/archive/refs/tags/v0.23.0.tar.gz -P /tmp/mmseg \
&& tar -xvf /tmp/mmseg/v0.23.0.tar.gz -C /tmp/mmseg

RUN pip3 install supervisely==6.73.229
LABEL python_sdk_version=6.73.229
RUN pip3 install supervisely==6.73.242
LABEL python_sdk_version=6.73.242
4 changes: 2 additions & 2 deletions serve/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"serve"
],
"description": "Deploy model as REST API service",
"docker_image": "supervisely/mmseg:1.3.17",
"min_instance_version": "6.12.5",
"docker_image": "supervisely/mmseg:1.3.18",
"min_instance_version": "6.12.12",
"entrypoint": "python -m uvicorn main:m.app --app-dir ./serve/src --host 0.0.0.0 --port 8000 --ws websockets",
"port": 8000,
"task_location": "application_sessions",
Expand Down
2 changes: 1 addition & 1 deletion serve/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# git+https://github.com/supervisely/supervisely.git@some-test-branch

supervisely==6.73.229
supervisely==6.73.242

openmim
ffmpeg-python==0.2.0
Expand Down
31 changes: 31 additions & 0 deletions serve/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,26 @@ def load_model(
self.model.eval()
self.model = revert_sync_batchnorm(self.model)

# Set checkpoint info
if model_source == "Pretrained models":
custom_checkpoint_path = None
else:
sly.logger.info(f"Custom checkpoint path: {checkpoint_url}")
custom_checkpoint_path = checkpoint_url
file_id = self.api.file.get_info_by_path(team_id, checkpoint_url).id
checkpoint_url = self.api.file.get_url(file_id)
if arch_type is None:
arch_type = self.parse_arch_type(cfg)

self.checkpoint_info = sly.nn.inference.CheckpointInfo(
checkpoint_name=checkpoint_name,
model_name=self.selected_model_name,
architecture=arch_type,
checkpoint_url=checkpoint_url,
custom_checkpoint_path=custom_checkpoint_path,
model_source=model_source,
)

except KeyError as e:
raise KeyError(f"Error loading config file: {local_config_path}. Error: {e}")

Expand Down Expand Up @@ -354,6 +374,17 @@ def get_models(self):
model_config[model_meta["model_name"]]["checkpoints"].append(checkpoint_info)
return model_config

def parse_arch_type(self, cfg: Config) -> str:
try:
arch_type = cfg.model.backbone.type
try:
arch_type += f"_{cfg.model.backbone.arch}"
except:
pass
return arch_type
except Exception as e:
sly.logger.warning(f"Error parsing model name: {e}")

def get_classes(self) -> List[str]:
return self.class_names # e.g. ["cat", "dog", ...]

Expand Down
4 changes: 2 additions & 2 deletions train/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"train"
],
"description": "Dashboard to configure, start and monitor training",
"docker_image": "supervisely/mmseg:1.3.17",
"min_instance_version": "6.12.5",
"docker_image": "supervisely/mmseg:1.3.18",
"min_instance_version": "6.12.12",
"main_script": "train/src/main.py",
"gui_template": "train/src/gui.html",
"task_location": "workspace_tasks",
Expand Down
2 changes: 1 addition & 1 deletion train/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# git+https://github.com/supervisely/supervisely.git@some-test-branch

supervisely==6.73.229
supervisely==6.73.242

openmim
ffmpeg-python==0.2.0
Expand Down

0 comments on commit 53c1eea

Please sign in to comment.