Skip to content

Commit

Permalink
Fix H-label & export with explain
Browse files Browse the repository at this point in the history
  • Loading branch information
harimkang committed Apr 5, 2024
1 parent d4c71e9 commit 249035b
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 503 deletions.
1 change: 0 additions & 1 deletion src/otx/algo/classification/backbones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from .otx_efficientnet import OTXEfficientNet
from .otx_efficientnet_v2 import OTXEfficientNetV2
# from .otx_mobilenet_v3 import OTXMobileNetV3
from .mobilenet_v3 import OTXMobileNetV3

__all__ = ["OTXEfficientNet", "OTXEfficientNetV2", "OTXMobileNetV3"]
368 changes: 0 additions & 368 deletions src/otx/algo/classification/backbones/otx_mobilenet_v3.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/otx/algo/classification/classifier/base_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def _forward_explain(self, images: torch.Tensor) -> dict[str, torch.Tensor | lis
pred_results = self.head._get_predictions(logits) # noqa: SLF001
# H-Label Classification Case
if isinstance(pred_results, dict):
scores = pred_results["pred_scores"].unbind(0)
preds = pred_results["pred_labels"].unbind(0)
scores = pred_results["pred_scores"]
preds = pred_results["pred_labels"]
else:
scores = pred_results.unbind(0)
preds = logits.argmax(-1, keepdim=True).unbind(0)
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/classification/heads/hlabel_cls_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def loss(self, feats: tuple[torch.Tensor], labels: torch.Tensor, **kwargs) -> to
head_gt = head_gt[valid_mask]
if len(head_gt) > 0:
head_logits = head_logits[valid_mask, :]
loss_score += self.multiclass_loss(head_logits, head_gt) / head_logits.size(0)
loss_score += self.multiclass_loss(head_logits, head_gt)
num_effective_heads_in_batch += 1

Check warning on line 107 in src/otx/algo/classification/heads/hlabel_cls_head.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algo/classification/heads/hlabel_cls_head.py#L103-L107

Added lines #L103 - L107 were not covered by tests

if num_effective_heads_in_batch > 0:
Expand Down
Loading

0 comments on commit 249035b

Please sign in to comment.