Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run benchmark after training. Other improvements (project conversion, progress bar, search for bg class) #61

Merged
merged 56 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a948987
add checkpoint info
NikolaiPetukhov Oct 31, 2024
40ade75
Create requirements.txt
NikolaiPetukhov Oct 31, 2024
633d10f
add packaging
NikolaiPetukhov Nov 1, 2024
3841820
add setuptools
NikolaiPetukhov Nov 1, 2024
27dd67a
remove setuptools from requirements
NikolaiPetukhov Nov 1, 2024
064baf0
add setuptools
NikolaiPetukhov Nov 1, 2024
55ccf0a
test
almazgimaev Nov 13, 2024
26abf84
detect bg class name
almazgimaev Nov 19, 2024
8d23a6a
add benchmark, update serve class, add custom progress ...
almazgimaev Nov 20, 2024
6759ce4
fix import
almazgimaev Nov 20, 2024
22638c7
test requirements, fix import
almazgimaev Nov 20, 2024
3aafcdc
add benchmark requirements
almazgimaev Nov 20, 2024
c488921
test
almazgimaev Nov 20, 2024
771049f
fix benchmark progress
almazgimaev Nov 20, 2024
0bab59d
temp comment ui elements
almazgimaev Nov 21, 2024
d51c6e8
wip
almazgimaev Nov 21, 2024
faa97d6
set new event loop
almazgimaev Nov 21, 2024
f5c507d
fix corner case
almazgimaev Nov 21, 2024
1ac91f7
fix checkpoint count
almazgimaev Nov 21, 2024
946fb55
revert
almazgimaev Nov 21, 2024
4e47305
fix
almazgimaev Nov 21, 2024
a0fc39b
fix
almazgimaev Nov 21, 2024
06b97fb
fix checkpoint_url, checkpoint_path and arch type
almazgimaev Nov 28, 2024
3752536
update Dockerfile
almazgimaev Nov 29, 2024
7ac8be9
update Dockerfile
almazgimaev Nov 29, 2024
6b67cbe
update requirements
almazgimaev Nov 29, 2024
d1fdd28
update deps
almazgimaev Nov 29, 2024
61551cf
run becnhmark
almazgimaev Dec 12, 2024
10b662e
change sdk branch
almazgimaev Dec 12, 2024
6bebfe8
updatee uvicorn params
almazgimaev Dec 12, 2024
3054c23
fix
almazgimaev Dec 12, 2024
2e3f48b
fix checkpoinr path and add debug logs
almazgimaev Dec 12, 2024
e6bd1da
set event loop
almazgimaev Dec 12, 2024
59ddb68
wip
almazgimaev Dec 12, 2024
b78510c
get trainval sets
almazgimaev Dec 12, 2024
1288e3a
wip
almazgimaev Dec 12, 2024
102ba38
Merge branch 'main' into benchmark
almazgimaev Dec 13, 2024
3782da6
fix progress and template
almazgimaev Dec 13, 2024
3eafaef
handle progress corner case
almazgimaev Dec 13, 2024
323ce34
show notification and progress.
almazgimaev Dec 13, 2024
e01eb11
cupy-cuda111 added
almazgimaev Dec 13, 2024
d2a8433
update label icon, remove cupy
almazgimaev Dec 13, 2024
a40a544
remove latest if saveLast is False but file exists
almazgimaev Dec 13, 2024
1435e4a
refactor prepare_segmentation_data
almazgimaev Dec 13, 2024
9904353
fix path
almazgimaev Dec 13, 2024
39172a3
fix bg class name and color. Use local checkpoint
almazgimaev Dec 13, 2024
bca1a85
Update supervisely python SDK version to 6.73.255
almazgimaev Dec 13, 2024
66e037b
upgrade SDK version
almazgimaev Dec 13, 2024
83af6b7
update Dockerfile
almazgimaev Dec 16, 2024
107050c
stop the model server
almazgimaev Dec 16, 2024
146d484
fix dataset split
almazgimaev Dec 16, 2024
e73f05b
rollback prepare_segmentation_data
almazgimaev Dec 16, 2024
75858e5
prepare_segmentation_data: add progress
almazgimaev Dec 16, 2024
2dff200
prepare_segmentation_data: handle bg class name and color
almazgimaev Dec 16, 2024
12f05bc
prepare_segmentation_data: using palette_lookup to speed up conversat…
almazgimaev Dec 16, 2024
16af170
remove unused code
almazgimaev Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.242
LABEL python_sdk_version=6.73.242
RUN pip3 install supervisely[model-benchmark]==6.73.255
LABEL python_sdk_version=6.73.255
2 changes: 1 addition & 1 deletion serve/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"serve"
],
"description": "Deploy model as REST API service",
"docker_image": "supervisely/mmseg:1.3.18",
"docker_image": "supervisely/mmseg:1.3.19",
"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,
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.242
supervisely==6.73.255

openmim
ffmpeg-python==0.2.0
Expand Down
4 changes: 2 additions & 2 deletions serve/local.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PYTHONUNBUFFERED=1

DEBUG_APP_DIR="/tmp/mmsegmentation"
DEBUG_CACHE_DIR="/tmp/mmsegmentation/cache"
DEBUG_APP_DIR="tmp/mmsegmentation"
DEBUG_CACHE_DIR="tmp/mmsegmentation/cache"

LOG_LEVEL="debug"
376 changes: 1 addition & 375 deletions serve/src/main.py

Large diffs are not rendered by default.

383 changes: 383 additions & 0 deletions serve/src/mmsegm_model.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion train/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"train"
],
"description": "Dashboard to configure, start and monitor training",
"docker_image": "supervisely/mmseg:1.3.18",
"docker_image": "supervisely/mmseg:1.3.19",
"min_instance_version": "6.12.12",
"main_script": "train/src/main.py",
"gui_template": "train/src/gui.html",
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.242
supervisely==6.73.255

openmim
ffmpeg-python==0.2.0
Expand Down
13 changes: 13 additions & 0 deletions train/local.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PYTHONUNBUFFERED=1

modal.state.slyProjectId=43218

context.teamId=447
context.workspaceId=680

AGENT_ID=341
TASK_ID=68365
DEBUG_APP_DIR="tmp/mmsegmentation"
DEBUG_CACHE_DIR="tmp/mmsegmentation/cache"

LOG_LEVEL="debug"
17 changes: 17 additions & 0 deletions train/src/sly_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import supervisely as sly


def get_bg_class_name(class_names):
possible_bg_names = ["background", "bg", "unlabeled", "neutral", "__bg__"]
for name in class_names:
if name.lower() in possible_bg_names:
return name
return None


def get_eval_results_dir_name(api, task_id, project_info):
task_info = api.task.get_info_by_id(task_id)
task_dir = f"{task_id}_{task_info['meta']['app']['name']}"
eval_res_dir = f"/model-benchmark/{project_info.id}_{project_info.name}/{task_dir}/"
eval_res_dir = api.file.get_free_dir_name(sly.env.team_id(), eval_res_dir)
return eval_res_dir
7 changes: 6 additions & 1 deletion train/src/sly_logger_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import supervisely as sly
from sly_train_progress import get_progress_cb, set_progress, add_progress_to_request
import sly_globals as g
from sly_functions import get_bg_class_name
import classes as cls
import math

Expand Down Expand Up @@ -126,7 +127,11 @@ def _log_info(self, log_dict, runner):
for metric_name, metrics in class_metrics.items():
if f"m{metric_name}" not in g.evalMetrics:
continue
classes = cls.selected_classes + ["__bg__"]
bg = get_bg_class_name(cls.selected_classes)
if bg is None:
classes = cls.selected_classes + ["__bg__"]
else:
classes = cls.selected_classes
for class_ind, class_name in enumerate(classes):
fields.extend(
[
Expand Down
9 changes: 9 additions & 0 deletions train/src/sly_mmsegm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys

sys.path.insert(0, "../")

from serve.src.mmsegm_model import MMSegmentationModel


class MMSegmentationModelBench(MMSegmentationModel):
in_train = True
2 changes: 1 addition & 1 deletion train/src/ui/classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</sly-el-table-selection-container>
<sly-field
title="INFO: Background Class"
description="background class (name: __bg__, color: [0, 0, 0]) will be added automatically"
description="if background class is not selected or not exists, it will be added automatically (by default: name: __bg__, color: [0, 0, 0])"
style="padding-top: 0; padding-bottom: 0; margin: 10px 5px"
>
<sly-icon
Expand Down
12 changes: 12 additions & 0 deletions train/src/ui/hyperparameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
<span class="ml5">iterations</span>
</div>
</sly-field>
<sly-field title="Run Model Benchmark evaluation">
<el-switch v-model="state.runBenchmark"
on-color="#13ce66" off-color="#B8B8B8"
:disabled="data.done6">
</el-switch>
</sly-field>
<sly-field title="Run Speed test">
<el-switch v-model="state.runSpeedTest"
on-color="#13ce66" off-color="#B8B8B8"
:disabled="data.done6">
</el-switch>
</sly-field>
</el-tab-pane>
<el-tab-pane label="Checkpoints" name="checkpoints">
<sly-field title="Checkpoints interval"
Expand Down
4 changes: 3 additions & 1 deletion train/src/ui/hyperparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def init_general(state):

state["valInterval"] = 1
state["logConfigInterval"] = 5
state["runBenchmark"] = True
state["runSpeedTest"] = True

def init_checkpoints(state):
state["checkpointInterval"] = 1
Expand Down Expand Up @@ -99,4 +101,4 @@ def use_hyp(api: sly.Api, task_id, context, state, app_logger):
{"field": "state.disabled7", "payload": False},
{"field": "state.activeStep", "payload": 7},
]
g.api.app.set_fields(g.task_id, fields)
g.api.app.set_fields(g.task_id, fields)
29 changes: 29 additions & 0 deletions train/src/ui/monitoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
>
</div>
</div>
<div v-if="data.benchmarkUrl">
<sly-field title="" description="Open the Model Benchmark evaluation report.">
<a slot="title" target="_blank" :href="data.benchmarkUrl">Evaluation Report</a>
<sly-icon
slot="icon"
:options="{ color: '#dcb0ff', bgColor: '#faebff', className: 'zmdi zmdi-assignment' }"
/>
</sly-field>
</div>
<sly-field v-if="state.preparingData" class="mt10">
<b style="color: #20a0ff"
>Preparing segmentation data (it may take a few minutes)...</b
Expand All @@ -103,6 +112,26 @@
</div>
<el-progress :percentage="data.progressPercentUploadDir"></el-progress>
</div>
<div v-if="state.benchmarkInProgress">
<i class="zmdi zmdi-info mr5" style="color: #20a0ff"></i>
<span style="color: #5a6772"
>Model Benchmark evaluation is in progress...</span
>
</div>
<div v-if="state.benchmarkInProgress && data.progressBenchmark" class="mt10">
<div style="color: #20a0ff">
{{data.progressBenchmark}}: {{data.progressCurrentBenchmark}} /
{{data.progressTotalBenchmark}}
</div>
<el-progress :percentage="data.progressPercentBenchmark"></el-progress>
</div>
<div v-if="data.progressTqdm" class="mt10">
<div style="color: #20a0ff">
{{data.progressTqdm}}: {{data.progressCurrentTqdm}} /
{{data.progressTotalTqdm}}
</div>
<el-progress :percentage="data.progressPercentTqdm"></el-progress>
</div>
<div v-if="data.progressEpoch" class="mt10">
<div style="color: #20a0ff">
{{data.progressEpoch}}: {{data.progressCurrentEpoch}} /
Expand Down
Loading
Loading