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

Fix classification rt_info #3922

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/otx/core/model/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def _export_parameters(self) -> TaskLevelExportParameters:
task_type="classification",
multilabel=False,
hierarchical=False,
output_raw_scores=True,
)

@property
Expand Down Expand Up @@ -279,6 +280,7 @@ def _export_parameters(self) -> TaskLevelExportParameters:
multilabel=True,
hierarchical=False,
confidence_threshold=0.5,
output_raw_scores=True,
)

@property
Expand Down Expand Up @@ -401,6 +403,7 @@ def _export_parameters(self) -> TaskLevelExportParameters:
multilabel=False,
hierarchical=True,
confidence_threshold=0.5,
output_raw_scores=True,
)

@property
Expand Down
6 changes: 6 additions & 0 deletions src/otx/core/types/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class TaskLevelExportParameters:
Only specified for the classification task.
hierarchical (bool | None): Whether it is hierarchical or not.
Only specified for the classification task.
output_raw_scores (bool | None): Whether to output raw scores.
Only specified for the classification task.
confidence_threshold (float | None): Confidence threshold for model prediction probability.
It is used only for classification tasks, detection and instance segmentation tasks.
iou_threshold (float | None): The Intersection over Union (IoU) threshold
Expand All @@ -60,6 +62,7 @@ class TaskLevelExportParameters:
# (Optional) Classification tasks
multilabel: bool | None = None
hierarchical: bool | None = None
output_raw_scores: bool | None = None

# (Optional) Classification tasks, detection and instance segmentation task
confidence_threshold: float | None = None
Expand Down Expand Up @@ -133,6 +136,9 @@ def to_metadata(self) -> dict[tuple[str, str], str]:
if self.hierarchical is not None:
metadata[("model_info", "hierarchical")] = str(self.hierarchical)

if self.output_raw_scores is not None:
metadata[("model_info", "output_raw_scores")] = str(self.output_raw_scores)

if self.confidence_threshold is not None:
metadata[("model_info", "confidence_threshold")] = str(self.confidence_threshold)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/core/model/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_export_parameters(
assert model._export_parameters.task_type.lower() == "classification"
assert not model._export_parameters.multilabel
assert not model._export_parameters.hierarchical
assert model._export_parameters.output_raw_scores

model = OTXMultilabelClsModel(
label_info=1,
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/core/types/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def test_wrap(fxt_label_info, task_type):

multilabel = False
hierarchical = False
output_raw_scores = True
confidence_threshold = 0.0
iou_threshold = 0.0
return_soft_prediction = False
Expand All @@ -27,6 +28,7 @@ def test_wrap(fxt_label_info, task_type):
params = params.wrap(
multilabel=multilabel,
hierarchical=hierarchical,
output_raw_scores=output_raw_scores,
confidence_threshold=confidence_threshold,
iou_threshold=iou_threshold,
return_soft_prediction=return_soft_prediction,
Expand All @@ -44,6 +46,7 @@ def test_wrap(fxt_label_info, task_type):
assert metadata[("model_info", "return_soft_prediction")] == str(return_soft_prediction)
assert metadata[("model_info", "soft_threshold")] == str(soft_threshold)
assert metadata[("model_info", "blur_strength")] == str(blur_strength)
assert metadata[("model_info", "output_raw_scores")] == str(output_raw_scores)

# Tile config
assert ("model_info", "tile_size") in metadata
Expand Down
Loading