Skip to content

Commit

Permalink
Inference settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatkot committed Feb 5, 2024
1 parent c82f8a7 commit 2a793b3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
3 changes: 3 additions & 0 deletions project_dataset/src/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

# endregion

# region ui-consants
deployed_nn_tags = ["deployed_nn"]
inference_modes = ["full image", "sliding window"]
add_predictions_modes = ["merge with existing labels", "replace existing labels"]

ann_cache = defaultdict(list) # only one (current) image in cache
project_info = None
Expand Down
5 changes: 4 additions & 1 deletion project_dataset/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
from supervisely.app.widgets import Container

import project_dataset.src.ui.connect_nn as connect_nn
import project_dataset.src.ui.inference_settings as inference_settings
import project_dataset.src.ui.input_data as input_data
import project_dataset.src.ui.nn_info as nn_info

layout = Container(widgets=[input_data.card, connect_nn.card, nn_info.card])
layout = Container(
widgets=[input_data.card, connect_nn.card, nn_info.card, inference_settings.card]
)

app = sly.Application(layout=layout)
7 changes: 7 additions & 0 deletions project_dataset/src/ui/connect_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from supervisely.app.widgets import Button, Card, Container, ModelInfo, SelectAppSession, Text

import project_dataset.src.globals as g
import project_dataset.src.ui.inference_settings as inference_settings
import project_dataset.src.ui.nn_info as nn_info

select_session = SelectAppSession(g.team_id, g.deployed_nn_tags)
Expand Down Expand Up @@ -58,6 +59,9 @@ def model_selected():
nn_info.card.unlock()
nn_info.card.uncollapse()

inference_settings.card.unlock()
inference_settings.card.uncollapse()


@disconnect_button.click
def model_changed():
Expand All @@ -72,6 +76,9 @@ def model_changed():
nn_info.card.lock()
nn_info.card.collapse()

inference_settings.card.lock()
inference_settings.card.collapse()


def connect_to_model():
try:
Expand Down
52 changes: 52 additions & 0 deletions project_dataset/src/ui/inference_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from supervisely.app.widgets import Card, Checkbox, Container, Editor, Field, Input, Select

import project_dataset.src.globals as g

inference_mode = Select(items=[Select.Item(mode) for mode in g.inference_modes])
inference_mode.set_value(g.inference_modes[0])
mode_field = Field(
content=inference_mode,
title="Inference mode",
description="Select how to process images: full images or using sliding window.",
)

class_tag_suffix = Input(value="model", minlength=1)
class_tag_suffix_field = Field(
content=class_tag_suffix,
title="Class and tag suffix",
description="Suffix that will be added to class and tag names.",
)
always_add_suffix = Checkbox("Always add suffix to model predictions")

add_predictions_mode = Select(items=[Select.Item(mode) for mode in g.add_predictions_modes])
add_predictions_mode.set_value(g.add_predictions_modes[0])
add_predictions_mode_field = Field(
content=add_predictions_mode,
title="Add predictions mode",
description="Select how to add predictions to the project: by merging with existing labels or by replacing them.",
)

additional_settings = Editor()
additional_settings_field = Field(
content=additional_settings,
title="Additional settings",
description="Model specific inference settings in YAML format.",
)

card = Card(
"4️⃣ Inference settings",
"Choose additional settings for model inference.",
content=Container(
[
mode_field,
class_tag_suffix_field,
always_add_suffix,
add_predictions_mode_field,
additional_settings_field,
]
),
collapsable=True,
lock_message="Connect to the deployed neural network on step 2️⃣.",
)
card.lock()
card.collapse()

0 comments on commit 2a793b3

Please sign in to comment.