From ce13f1170ce048604df15c0e2328556ccda103c1 Mon Sep 17 00:00:00 2001 From: "Shin, Eunwoo" Date: Wed, 28 Aug 2024 16:03:08 +0900 Subject: [PATCH 1/3] specify data type --- src/otx/core/data/dataset/detection.py | 3 ++- src/otx/core/data/dataset/instance_segmentation.py | 1 + src/otx/core/model/detection.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/otx/core/data/dataset/detection.py b/src/otx/core/data/dataset/detection.py index 8094638b457..afa2a2a73f6 100644 --- a/src/otx/core/data/dataset/detection.py +++ b/src/otx/core/data/dataset/detection.py @@ -49,8 +49,9 @@ def _get_item_impl(self, index: int) -> DetDataEntity | None: bboxes, format=tv_tensors.BoundingBoxFormat.XYXY, canvas_size=img_shape, + dtype=torch.float32, ), - labels=torch.as_tensor([ann.label for ann in bbox_anns]), + labels=torch.as_tensor([ann.label for ann in bbox_anns], dtype=torch.int32), ) return self._apply_transforms(entity) diff --git a/src/otx/core/data/dataset/instance_segmentation.py b/src/otx/core/data/dataset/instance_segmentation.py index 0a3abaeb877..d154ebd4ab2 100644 --- a/src/otx/core/data/dataset/instance_segmentation.py +++ b/src/otx/core/data/dataset/instance_segmentation.py @@ -75,6 +75,7 @@ def _get_item_impl(self, index: int) -> InstanceSegDataEntity | None: bboxes, format=tv_tensors.BoundingBoxFormat.XYXY, canvas_size=img_shape, + dtype=torch.float32, ), masks=tv_tensors.Mask(masks, dtype=torch.uint8), labels=torch.as_tensor(labels), diff --git a/src/otx/core/model/detection.py b/src/otx/core/model/detection.py index 437aa6b6e96..f2da68b2b7f 100644 --- a/src/otx/core/model/detection.py +++ b/src/otx/core/model/detection.py @@ -297,7 +297,7 @@ def _convert_pred_entity_to_compute_metric( "preds": [ { "boxes": bboxes.data, - "scores": scores, + "scores": scores.type(torch.float32), "labels": labels, } for bboxes, scores, labels in zip( From dd3c311fdd6b0c60db34456d34e93b6e2af22f71 Mon Sep 17 00:00:00 2001 From: "Shin, Eunwoo" Date: Wed, 28 Aug 2024 16:29:18 +0900 Subject: [PATCH 2/3] add docstring to notify need to update FMeasure for distributed training --- src/otx/core/metrics/fmeasure.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/otx/core/metrics/fmeasure.py b/src/otx/core/metrics/fmeasure.py index 6cc44850a2f..d3c71285f94 100644 --- a/src/otx/core/metrics/fmeasure.py +++ b/src/otx/core/metrics/fmeasure.py @@ -636,6 +636,8 @@ class FMeasure(Metric): IoU > threshold are reduced to one. This threshold can be determined automatically by setting `vary_nms_threshold` to True. + # TODO(someone): need to update for distriubted training. refer https://lightning.ai/docs/torchmetrics/stable/pages/implement.html + Args: label_info (int): Dataclass including label information. vary_nms_threshold (bool): if True the maximal F-measure is determined by optimizing for different NMS threshold From 09bc0b13528899ac1b5cd6592953cacc1d8f7d30 Mon Sep 17 00:00:00 2001 From: "Shin, Eunwoo" Date: Wed, 28 Aug 2024 16:53:48 +0900 Subject: [PATCH 3/3] update label dtype from int32 to long --- src/otx/core/data/dataset/detection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/otx/core/data/dataset/detection.py b/src/otx/core/data/dataset/detection.py index afa2a2a73f6..feba0d454b9 100644 --- a/src/otx/core/data/dataset/detection.py +++ b/src/otx/core/data/dataset/detection.py @@ -51,7 +51,7 @@ def _get_item_impl(self, index: int) -> DetDataEntity | None: canvas_size=img_shape, dtype=torch.float32, ), - labels=torch.as_tensor([ann.label for ann in bbox_anns], dtype=torch.int32), + labels=torch.as_tensor([ann.label for ann in bbox_anns], dtype=torch.long), ) return self._apply_transforms(entity)